No please do not lock it.
Im actually at work, and i used my mobile to reply, so i could not actually paste my codes and all.
Grumpy_Mike:
You do know that opening and closing the serial monitor resets your arduino.
I still don't see how you know it is reaseting. Maybe you have a faulty USB cable.
Yes i do know it resets the Arduino.
I did change the USB cable this morning, same thing happen.
For the 1 led blinking i used the following code, in the example itself:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
How do i know it is reseting:
Ok! may be i am wrong, i presume so because, when my led blinks within an interval of 1000 ms and when you press the reset button manually and intentionally, you can notice that your led blinks 3 to 4 times rapidly, both the on-board and the externally connected led. I presume a reset has been achieved.
I confirmed it to be reset because, with my first sketch which i posted on my first post, i have a switch as input, with the same switch being pressed, i have 3 light modes.
Light mode 0= ALL OFF
Light mode 1 = All led blinks
when pressing reset manually and intentionally my outputs will go off and i need to press my switch again to activate my outputs as in the sketch:
/*
- Bike light, revision 3: blinky
*/
int switchPin = 2; // switch is connected to pin 2
int led1Pin = 12;
int led2Pin = 11;
int led3Pin = 10;
int led4Pin = 9;
int led5Pin = 8;
int val; // variable for reading the pin status
int val2; // variable for reading the delayed status
int buttonState; // variable to hold the button state
int lightMode = 0; // What mode is the light in?
void setup() {
pinMode(switchPin, INPUT); // Set the switch pin as input
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
pinMode(led3Pin, OUTPUT);
pinMode(led4Pin, OUTPUT);
pinMode(led5Pin, OUTPUT);
Serial.begin(9600); // Set up serial communication at 9600bps
buttonState = digitalRead(switchPin); // read the initial state
}
void loop(){
val = digitalRead(switchPin); // read input value and store it in val
delay(10); // 10 milliseconds is a good amount of time
val2 = digitalRead(switchPin); // read the input again to check for bounces
if (val == val2) { // make sure we got 2 consistant readings!
if (val != buttonState) { // the button state has changed!
if (val == LOW) { // check if the button is pressed
if (lightMode == 0) { // light is off
lightMode = 1; // turn light on!
} else {
lightMode = 0; // turn light off!
}
}
}
buttonState = val; // save the new state in our variable
}
// Now do whatever the lightMode indicates
if (lightMode == 1) {
digitalWrite(led1Pin, HIGH);
digitalWrite(led2Pin, HIGH);
digitalWrite(led3Pin, HIGH);
digitalWrite(led4Pin, HIGH);
digitalWrite(led5Pin, HIGH);
delay(100);
digitalWrite(led1Pin, LOW);
digitalWrite(led2Pin, LOW);
digitalWrite(led3Pin, LOW);
digitalWrite(led4Pin, LOW);
digitalWrite(led5Pin, LOW);
delay(100);
}
// If lightmode is 0, we dont have to do anything because the LEDs are already off!
}
Evening i will try to post my circuit as well.
Thanks
taz ...