Advertisement
Guest User

Analog Read Program

a guest
Dec 11th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. //This is a 3 light blinking Program
  2. /*
  3. * This program will turn On one light at the time
  4. * then we will blink all light 5 times
  5. * Lane Herbert
  6. * 11/30/2017
  7. */
  8. const int PinLed1 = 9;
  9. const int PinLed2 = 10;
  10. const int PinLed3 = 11;
  11. const int PinLed4 = 5;
  12. const int PinLed5 = 6;
  13. const int PinBut1 = 7;
  14. const int PinPot = A0;
  15. int PotValue=0;
  16.  
  17.  
  18.  
  19. void setup()
  20. {
  21. pinMode(PinLed1, OUTPUT);
  22. pinMode(PinLed2, OUTPUT);
  23. pinMode(PinLed3, OUTPUT);
  24. pinMode(PinLed4, OUTPUT);
  25. pinMode(PinLed5, OUTPUT);
  26. pinMode(PinPot,INPUT);
  27. Serial.begin(9600);
  28. }
  29. void blinky () {
  30.  
  31. for(int i=0; i < 5; i ++)
  32. {
  33.  
  34. digitalWrite(PinLed1, LOW);
  35. digitalWrite(PinLed2, LOW);
  36. digitalWrite(PinLed3, LOW);
  37. digitalWrite(PinLed4, LOW);
  38. digitalWrite(PinLed5, LOW);
  39. delay(200);
  40. digitalWrite(PinLed1, HIGH);
  41. digitalWrite(PinLed2, HIGH);
  42. digitalWrite(PinLed3, HIGH);
  43. digitalWrite(PinLed4,HIGH);
  44. digitalWrite(PinLed5,HIGH);
  45. delay (200);
  46. }
  47. digitalWrite(PinLed1, LOW);
  48. digitalWrite(PinLed2, LOW);
  49. digitalWrite(PinLed3, LOW);
  50. digitalWrite(PinLed4,LOW);
  51. digitalWrite(PinLed5,LOW);
  52. }
  53.  
  54. void loop()
  55. {
  56. PotValue=analogRead (PinPot);
  57. Serial.println(PotValue);
  58. analogWrite(PinLed1, PotValue/4);
  59. analogWrite(PinLed2, PotValue/4);
  60. analogWrite(PinLed3, PotValue/4);
  61. analogWrite(PinLed4, PotValue/4);
  62. analogWrite(PinLed5, PotValue/4);
  63.  
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement