Advertisement
Razvii

Arduino Issue

Oct 8th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. void setup() {
  2. pinMode(2, OUTPUT);
  3. pinMode(3, OUTPUT);
  4. pinMode(4, OUTPUT);
  5. pinMode(5, OUTPUT);
  6. pinMode(6, OUTPUT);
  7. pinMode(7, OUTPUT);
  8. pinMode(8, OUTPUT);
  9. pinMode(9, OUTPUT);
  10. pinMode(10, OUTPUT);
  11. pinMode(11, OUTPUT);
  12. pinMode(12, OUTPUT);
  13. pinMode(13, OUTPUT);
  14. pinMode(16, INPUT);
  15. Serial.begin(9600);
  16.  
  17. }
  18.  
  19. int ledDelay = 0;
  20. int LED1 = 2;
  21. int LED2 = 2;
  22. int AnalogR = 0; //Analog input for a potentiometer that sets the delay
  23.  
  24.  
  25.  
  26. void loop() {
  27. ledDelay = map(analogRead(0), 0 , 1023, 1, 1000); //mapping the potentiometer input value to more manageable values
  28. digitalWrite(LED1, HIGH); // Sets LED1 high
  29. digitalWrite(LED2, HIGH); // Sets LED2 high
  30. Serial.println(ledDelay);
  31. delay(ledDelay); //delay based on potentiometer
  32. digitalWrite(LED1, LOW); // Turns off both LED's
  33. digitalWrite(LED2, LOW);
  34. LED1 = 1 + LED1; // Adds 1 to LED1, making it move to the next one
  35. LED2 = LED1 - 2; // sets the position of LED2 1 space apart from LED1
  36. if (LED1 >= 13){ //Resets LED1 to it's starting point once it reaches the end
  37. LED1 = 2;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement