NEWBIE Question:
My Test program turns the LED2 on as it should, nice and bright, however, when I download the real program LED 2 burns dim, Arduino only puts out 2.5 volts on the real program, and 5V on the test program.
I need someone to review my code to see if there's anything causing this. I can't find it.
I also would live to activate both Led"s on at the same time, if Both Switch 2 and 3 are made at the same time. Maybe someone could suggest a statement for this situation.
Test Program:
/int LED=12; //HERO board pin 13
int Switch1=2; //pin 2 will be attached to the switch
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
pinMode(Switch1, INPUT);
}
void loop() {
// within loop() Conditional input switch:
if (digitalRead(Switch1) == HIGH){
digitalWrite(LED, HIGH);
delay(10000);
}
else {
digitalWrite(LED, LOW); // turn LED OFF
}
}
Real Program:
int LED=13;
int LED2=12;
int Switch2=2;
int Switch3=3;
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
pinMode(Switch2, INPUT);
pinMode(Switch3, INPUT);
}
void loop() {
// within loop() Conditional input switch:
if( (digitalRead(Switch3) == HIGH))
{int n;
for (n = 1; n <= 10; n++)
{
digitalWrite(13, HIGH);
delay(250);
digitalWrite(13, LOW);
delay(250);
}
for (n = 1; n <= 10; n++)
{
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
}
else
{ if (digitalRead(Switch3) == LOW)
{ digitalWrite(13, LOW);
}
{ if (digitalRead(Switch2) == HIGH)
{
{ int n;
for (n = 1; n <= 10; n++)
{
digitalWrite(12, HIGH);
delay(250);
digitalWrite(12, LOW);
delay(250);
}
for (n = 1; n <= 10; n++)
{
digitalWrite(12, HIGH);
delay(500);
digitalWrite(12, LOW);
delay(500);
}
}
}else
{ if (digitalRead(Switch2) == LOW)
digitalWrite(12, LOW); }
}
}
