hi Guys
Been working on this and I got rid off the array I assume i did not need it to get the sequence to work.
I have been trying to work on method to use a button push using 'millis' command, but i am getting a little confused and again not sure if I am going along the correct route
I am sure how to generate the delay off timer and a random winning lamp at the end of the and then re-start the program again.
anyone with more experience who can help would be much appreciated
current code
const int buttonPin = 11;
int speed = 100;
boolean running = true;
long currentMillis =0;
long previousMillis =0;
void setup() {
pinMode (buttonPin, INPUT_PULLUP); // input for button
// set output for the 25 pins
for(int pin = 22; pin <= 46; pin++){
pinMode(pin,OUTPUT);
}
}
void loop() {
// set start state
for(int pin = 22; pin <= 46; pin++){
digitalWrite (pin, LOW);
}
// digital write high & read low for outputs without delays allows for program to works without delays
for(int highPin = 22; highPin <= 46; highPin++)
{
digitalWrite(highPin, HIGH);
readButton (speed);
digitalWrite(highPin, LOW);
readButton (speed);
}
}
// method for button to, not sure on this it does seam to stop and start the sequence running
void readButton(int delay) {
boolean buttonDown = false;
boolean buttonBackUp = false;
boolean input;
currentMillis = millis();
previousMillis = currentMillis;
while(currentMillis - previousMillis < delay) {
input = digitalRead(buttonPin);
if (input == LOW) {
buttonDown = true;
}
else if (buttonDown == true & input == HIGH) {
buttonBackUp = true;
}
currentMillis = millis();
}
if(buttonDown == true) {
running = false;
}
while(running == false & buttonBackUp == false){
input = digitalRead(buttonPin);
if(input == HIGH)
{
buttonBackUp = true;
}
}
int lastInput = HIGH;
while(running == false){
input = digitalRead(buttonPin);
if(input == LOW){
lastInput = LOW;
}
else if(input == HIGH & lastInput == HIGH) {
running = true;
}
}
}