Is there anyway of starting a loop that only requires one initial activation, e.g. pressing a button once as opposed to having to hold it?
Imagine this as a base but i dont want to have to hold the button down:
#include <Button.h>//Arduino Playground - HomePage
const byte ledPin = 13;
int Button = 12;
int val = 0;
int greenled = 8; //Led's and pins
int yellowled = 9;
int redled = 10;
void setup()
{
pinMode(greenled, OUTPUT); //Pinmodes of the leds
pinMode(yellowled, OUTPUT);
pinMode(redled, OUTPUT);
pinMode(Button, INPUT);
}
void loop()
{
val = digitalRead(Button); // read input value
if (val == HIGH){
digitalWrite(greenled, HIGH); //Green on for 5 seconds
delay(5000);
digitalWrite(greenled, LOW); //Green off, yellow on for 2 seconds
digitalWrite(yellowled, HIGH);
delay(2000);
digitalWrite(yellowled, LOW); //yellow off, red on for 5 seconds
digitalWrite(redled, HIGH);
delay(5000);
digitalWrite(yellowled, HIGH); //Yellow and red on for 2 seconds
delay(2000);
digitalWrite(redled, LOW); //Red and Yellow off
digitalWrite(yellowled, LOW);
}
}
I realise this is a basic thing to most of you but im a newbie and need help :(!
Any help with this would be mega
Thanks,
Danny