Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Arduino Stair Poject
- * With Infred Sensor And LED Lights On Either Sides Of The Stairs
- *
- *
- * Basic operation consists of motion being detected on either
- * the top step, or the bottom step and then starting a sequence of operation
- * with LEDs
- *
- */
- int ledPin1 = 2; // Pwm Pin 2
- int ledPin2 = 3; // Pwm Pin 3
- int ledPin3 = 4; // Pwm Pin 4
- int ledPin4 = 5; // Pwm Pin 5
- int ledPin5 = 6; // Pwm Pin 6
- int ledPin6 = 22; // Digital Pin 22 (i ran out of analog pins)
- int ledPin7 = 7; // Pwm Pin 7
- int ledPin8 = 8; // Pwm Pin 8
- int ledPin9 = 9; // Pwm Pin 9
- int ledPin10 = 10; // Pwm Pin 10
- int ledPin11 = 11; // Pwm Pin 11
- int ledPin12 = 12; // Pwm Pin 12
- int ledPin13 = 13; // Pwm Pin 13
- int inputPin1 = 24; // Infrared Sensor Top Stair 1
- int inputPin2 = 26; // Infrared Sensor Top Stair 2
- int inputPin3 = 28; // Infrared Sensor Bottom Stair 1
- int inputPin4 = 30; // Infrared Sensor Bottom Stair 2
- 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
- void setup(){
- pinMode(ledPin1, OUTPUT);
- pinMode(ledPin2, OUTPUT);
- pinMode(ledPin3, OUTPUT);
- pinMode(ledPin4, OUTPUT);
- pinMode(ledPin5, OUTPUT);
- pinMode(ledPin6, OUTPUT);
- pinMode(ledPin7, OUTPUT);
- pinMode(ledPin8, OUTPUT);
- pinMode(ledPin9, OUTPUT);
- pinMode(ledPin10, OUTPUT);
- pinMode(ledPin11, OUTPUT);
- pinMode(ledPin12, OUTPUT);
- pinMode(ledPin13, OUTPUT);
- pinMode(inputPin1, INPUT);
- pinMode(inputPin2, INPUT);
- pinMode(inputPin3, INPUT);
- pinMode(inputPin4, INPUT);
- }
- void loop()
- {
- int val1 = digitalRead(inputPin1);
- int val2 = digitalRead(inputPin2);
- if (val1 == HIGH) {
- for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5){
- analogWrite(ledPin1, fadeValue);
- delay(40);
- }
- for(int fadeValue = 0 ; fadeValue >= 255; fadeValue -=5){
- analogWrite(ledPin1, fadeValue);
- delay(100);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement