Created
September 10, 2018 16:56
-
-
Save jatkins/62f5836e317de7d5d8d1058a2abeaa02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code was writen for a Grad-Students Art Project at ETSU | |
// The concept for the project was a set of motion sencors connected | |
// to an arduino would trigger a change of LEDs | |
// | |
// Date: 2014-09-15 | |
// Author: Jacob Atkins (http://jatkins.us | |
// Writen For: Ricky Bump (http://www.rickeybump.com/) | |
// | |
// EDIT AS NEEDED | |
int pirPin[] = {5,6,7,8,9,10}; // Pins that the PIR Sensors are connected to | |
int ledPin[] = {20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35}; // Pins that the leds in order are connected to | |
int timer = 500; // Time between LED change on RiderCode | |
int count = 0; | |
int time = 5000; | |
int pir[5] = {LOW, LOW, LOW, LOW, LOW}; | |
int val[5] = {0,0,0,0,0}; | |
void setup() { | |
Serial.begin(9600); | |
for(count=0;count<25;count++) { | |
pinMode(ledPin[count], OUTPUT); | |
} | |
delay(1000); | |
for(count=0;count<5;count++) { | |
pinMode(pirPin[count], INPUT); | |
} | |
Serial.println("Testing LEDs"); | |
for(int loop_count=1;loop_count<5;loop_count++){ | |
for(count=0;count<25;count++){ | |
digitalWrite(ledPin[count], HIGH); | |
delay(time); | |
digitalWrite(ledPin[count+1], HIGH); | |
delay(time); | |
digitalWrite(ledPin[count], LOW); | |
} | |
time = time - 1000; | |
} | |
} | |
void loop() { | |
for(int i=0;i<5;i++){ | |
val[i] = digitalRead(pirPin[i]); | |
if(val[i] == HIGH) { | |
ride(i); | |
if(pir[i] == LOW) { | |
Serial.println("Motion on Pir " + i); | |
pir[i] = HIGH; | |
} | |
} else { | |
if(pir[i] == HIGH){ | |
Serial.println("Motion stable on PIR " + i); | |
pir[i] = LOW; | |
} | |
} | |
} | |
} | |
void ride(int chain){ | |
switch(chain){ | |
case 0: | |
for(int i=0;i<9;i++){ | |
digitalWrite(ledPin[i], HIGH); | |
delay(timer); | |
digitalWrite(ledPin[i], LOW); | |
} | |
break; | |
case 1: | |
for(int i=9;i<12;i++){ | |
digitalWrite(ledPin[i], HIGH); | |
delay(timer); | |
digitalWrite(ledPin[i], LOW); | |
} | |
break; | |
case 2: | |
for(int i=13;i<16;i++){ | |
digitalWrite(ledPin[i], HIGH); | |
delay(timer); | |
digitalWrite(ledPin[i], LOW); | |
} | |
break; | |
case 3: | |
for(int i=17;i<19;i++){ | |
digitalWrite(ledPin[i], HIGH); | |
delay(timer); | |
digitalWrite(ledPin[i], LOW); | |
} | |
break; | |
case 4: | |
for(int i=20;i<23;i++){ | |
digitalWrite(ledPin[i], HIGH); | |
delay(timer); | |
digitalWrite(ledPin[i], LOW); | |
} | |
break; | |
default: | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment