Advertisement
makispaiktis

Arduino - Λαμπάκια ανάβουν σερί το ένα μετά το άλλο

Apr 16th, 2019 (edited)
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define blue 3
  2. #define green 5
  3. #define red 6
  4.  
  5. char currentColor = 'r';
  6. char nextColor = 'g';
  7.  
  8. void setup() {
  9.   // put your setup code here, to run once:
  10.   pinMode(blue, OUTPUT);
  11.   pinMode(green, OUTPUT);
  12.   pinMode(red, OUTPUT);
  13.  
  14.   digitalWrite(blue, HIGH);
  15.   digitalWrite(green, HIGH);
  16.   digitalWrite(red, LOW);
  17.  
  18. }
  19.  
  20. void loop() {
  21.   // put your main code here, to run repeatedly:
  22.   //eixame led anodiko ara 8elame thn antistash sthn tash kai anavame ka8e xrwma kanontas to LOW
  23.  
  24.  
  25.   if(currentColor == 'r') {
  26.     digitalWrite(green, LOW);
  27.     digitalWrite(red, HIGH);
  28.     currentColor = 'g';
  29.   }
  30.   else if(currentColor == 'g') {
  31.     digitalWrite(blue, LOW);
  32.     digitalWrite(green, HIGH);
  33.     currentColor = 'b';
  34.   }
  35.   else {
  36.     digitalWrite(red, LOW);
  37.     digitalWrite(blue, HIGH);
  38.     currentColor = 'r';
  39.   }
  40.  
  41.   delay(1000);
  42.  
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement