RaspBar

mod2_runLED

Oct 16th, 2021 (edited)
1,148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. /*
  2.  * Name: mod2_runLED.ino
  3.  * Date: 2021/10/14
  4.  * Author: fsc
  5.  * Version 1.0
  6.  * URL: https://wokwi.com/arduino/projects/312615861434188354
  7.  */
  8.  
  9. const int LED1 = 4; //red
  10. const int LED2 = 5; //green
  11. const int LED3 = 6; //blue
  12. const int LED4 = 7; //yellow
  13.  
  14. // aktuell aktive LED
  15. int current = LED1;
  16.  
  17. // Starten der setup-Funktion, wird nur einmal aufgerufen
  18. void setup()
  19. {
  20.     // alle 4 Pin als Ausgang initialisieren
  21.     pinMode(LED1, OUTPUT);
  22.     pinMode(LED2, OUTPUT);
  23.     pinMode(LED3, OUTPUT);
  24.     pinMode(LED4, OUTPUT);
  25. }
  26.  
  27. void loop()
  28. {
  29.     digitalWrite(current, HIGH); // LED ein
  30.     delay(500);
  31.     digitalWrite(current, LOW); // LED aus
  32.  
  33.     // zur nächsten LED wechseln
  34.     current = current + 1;
  35.     if (current > LED4)
  36.         current = LED1;
  37. }
Add Comment
Please, Sign In to add comment