From b80f32484d9ce88e3926e27e790bba209bc030ee Mon Sep 17 00:00:00 2001 From: Vladimir Garistov Date: Thu, 19 Oct 2023 16:13:10 +0300 Subject: [PATCH] Improved Reister_multiple example --- .../Register_multiple/Register_multiple.ino | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/Examples/GPIO/Register_multiple/Register_multiple.ino b/Examples/GPIO/Register_multiple/Register_multiple.ino index 68153ea..ce25aaf 100644 --- a/Examples/GPIO/Register_multiple/Register_multiple.ino +++ b/Examples/GPIO/Register_multiple/Register_multiple.ino @@ -1,25 +1,39 @@ +#define Y_U_SO_SLOW + void setup() { - pinMode(8, OUTPUT); - pinMode(9, OUTPUT); - pinMode(10, OUTPUT); - pinMode(11, OUTPUT); - digitalWrite(8, LOW); - digitalWrite(9, LOW); - digitalWrite(10, HIGH); - digitalWrite(11, HIGH); + #ifdef Y_U_SO_SLOW + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + digitalWrite(8, LOW); + digitalWrite(9, LOW); + digitalWrite(10, HIGH); + digitalWrite(11, HIGH); + #else + DDRB |= (1 << DDB0) | (1 << DDB1) | (1 << DDB2) | (1 << DDB3); + PORTB = (PORTB | (1 << DDB2) | (1 << DDB3)) & ~((1 << DDB0) | (1 << DDB1)); + #endif } void loop() { - delay(100); - digitalWrite(8, HIGH); - digitalWrite(9, HIGH); - digitalWrite(10, LOW); - digitalWrite(11, LOW); - delayMicroseconds(50); - digitalWrite(8, LOW); - digitalWrite(9, LOW); - digitalWrite(10, HIGH); - digitalWrite(11, HIGH); + #ifdef Y_U_SO_SLOW + delay(100); + digitalWrite(8, HIGH); + digitalWrite(9, HIGH); + digitalWrite(10, LOW); + digitalWrite(11, LOW); + delayMicroseconds(50); + digitalWrite(8, LOW); + digitalWrite(9, LOW); + digitalWrite(10, HIGH); + digitalWrite(11, HIGH); + #else + PORTB ^= (1 << DDB0) | (1 << DDB1) | (1 << DDB2) | (1 << DDB3); + delayMicroseconds(50); + PORTB ^= (1 << DDB0) | (1 << DDB1) | (1 << DDB2) | (1 << DDB3); + delay(100); + #endif } -- 2.39.5