HI guys!
I'm having trouble with my project, please help me!? I want to turn on 8 leds sequentially counting up, and then down for example 0000000, 00000001, 00000011, 00000111, 00001111, 00011111, 00111111, 01111111, 11111111, 11111110, 11111100, 11111000, 11110000, 11100000, 11000000, 10000000, 0000000. However, what i am struggling on is getting the arduino to run this protocol after a PIR sensor has been tripped. The code I have got so far is below:
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
int pirPin = 10;
const byte COL_COUNT = 8;
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(pirPin, INPUT);
}
void loop()
{
if (digitalRead(pirPin) == HIGH);
//*carry out protocol
if (digitalRead(pirPin) == LOW);
//*then do nothing hmm???
{
int col_data = 0;
for (int col = 0; col < COL_COUNT; col++)
bitWrite(col_data, col, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, col_data);
digitalWrite(latchPin, HIGH);
delay(600);
}
//*somewhere here all leds need to be on for a set period of time to walk up stairs
int col_data = 0;
for (int col = 0; col < COL_COUNT; col++)
{
bitWrite(col_data, col, LOW);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, col_data);
digitalWrite(latchPin, HIGH);
delay(600);
}
}
P.s I am new to this, and apriciate all replys smiley-grin, THANKYOU VERY MUCH