Advertisement
iyera20

Second Program: LED With Button Variation 3

Jun 7th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. /*
  2. * Atiriya Iyer
  3. * Veriation 3
  4. * Learning Digital Inputs
  5. */
  6. const int pinLED = 6;
  7. const int pinButton = 2;
  8. int readValue = 0;
  9. boolean lightOn = 0;
  10. void setup()
  11. {
  12. // put your setup code here, to run once:
  13. pinMode (pinButton, INPUT);
  14. pinMode (pinLED, OUTPUT);
  15.  
  16. Serial.begin(9600);
  17.  
  18. digitalWrite(pinLED, HIGH);
  19. delay(50);
  20. digitalWrite(pinLED, LOW);
  21.  
  22. }
  23.  
  24. void loop()
  25. {
  26. // put your main code here, to run repeatedly:
  27. readValue= digitalRead(pinButton);
  28.  
  29. if(readValue==1)
  30. {
  31. for(int i=0; i<=200; i++)
  32. {
  33. analogWrite(pinLED, i);
  34. delay (40);
  35. }
  36. }
  37. else
  38. {
  39. digitalWrite (pinLED, LOW);
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement