Hy guys i have a problem...
I wrote a code but i need to make it go for 10 seconds..I managed to put code for repeating code for 10 times but i need seconds.Code is with repeat code 10 times....
Can anyone help me with code for that?
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 3; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// the setup function runs once when you press reset or power the board
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
// initialize digital pin 13 as an output.
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
// the loop function runs over and over again forever
void loop()
{
int p = digitalRead(2);
if (p == HIGH)
for (int x = 0; x < 10; x++)
{
digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(9, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(9, LOW); // turn the LED on (HIGH is the voltage level)
delay(100);
digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
delay(100);
}
}