Advertisement
Guest User

Untitled

a guest
Sep 9th, 2012
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.13 KB | None | 0 0
  1. /* Arduino Stair Poject
  2.  * With Infred Sensor And LED Lights On Either Sides Of The Stairs
  3.  *
  4.  *
  5.  * Basic operation consists of motion being detected on either
  6.  * the top step, or the bottom step and then starting a sequence of operation
  7.  * with LEDs
  8.  *
  9.  */
  10.  
  11. int ledPin1 = 2;              // Pwm Pin 2
  12. int ledPin2 = 3;              // Pwm Pin 3
  13. int ledPin3 = 4;              // Pwm Pin 4
  14. int ledPin4 = 5;              // Pwm Pin 5
  15. int ledPin5 = 6;              // Pwm Pin 6
  16. int ledPin6 = 22;             // Digital Pin 22 (i ran out of analog pins)
  17. int ledPin7 = 7;              // Pwm Pin 7
  18. int ledPin8 = 8;              // Pwm Pin 8
  19. int ledPin9 = 9;              // Pwm Pin 9
  20. int ledPin10 = 10;            // Pwm Pin 10
  21. int ledPin11 = 11;            // Pwm Pin 11
  22. int ledPin12 = 12;            // Pwm Pin 12
  23. int ledPin13 = 13;            // Pwm Pin 13
  24. int inputPin1 = 24;           // Infrared Sensor Top Stair 1
  25. int inputPin2 = 26;           // Infrared Sensor Top Stair 2
  26. int inputPin3 = 28;           // Infrared Sensor Bottom Stair 1
  27. int inputPin4 = 30;           // Infrared Sensor Bottom Stair 2
  28. int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; // i saw this on a stair lighting sketch but every time i use it, it doesn't work
  29.  
  30.  
  31.  
  32. void setup(){
  33.   pinMode(ledPin1, OUTPUT);
  34.   pinMode(ledPin2, OUTPUT);
  35.   pinMode(ledPin3, OUTPUT);
  36.   pinMode(ledPin4, OUTPUT);
  37.   pinMode(ledPin5, OUTPUT);
  38.   pinMode(ledPin6, OUTPUT);
  39.   pinMode(ledPin7, OUTPUT);
  40.   pinMode(ledPin8, OUTPUT);
  41.   pinMode(ledPin9, OUTPUT);
  42.   pinMode(ledPin10, OUTPUT);
  43.   pinMode(ledPin11, OUTPUT);
  44.   pinMode(ledPin12, OUTPUT);
  45.   pinMode(ledPin13, OUTPUT);
  46.   pinMode(inputPin1, INPUT);
  47.   pinMode(inputPin2, INPUT);
  48.   pinMode(inputPin3, INPUT);
  49.   pinMode(inputPin4, INPUT);
  50. }
  51.  
  52. void loop()
  53. {
  54.   int val1 = digitalRead(inputPin1);
  55.   int val2 = digitalRead(inputPin2);
  56.   if (val1 == HIGH) {
  57.     for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5){
  58.       analogWrite(ledPin1, fadeValue);
  59.       delay(40);
  60.     }
  61.     for(int fadeValue = 0 ; fadeValue >= 255; fadeValue -=5){
  62.       analogWrite(ledPin1, fadeValue);
  63.       delay(100);
  64.     }
  65.   }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement