Newbie :) 'if' help
hi guys, got self arduino other day 
ive been going through beginner tutorials , sketches , learning basics, started learning 'if' statements , thought try , use 1 turn 2 led's 1 , off modifying blink example, example had 1 led running normal blink used second led in if statement opposite of led 1 does. reason wont work, obvious, led 1 blinks fine led 2 stays off. ill add sketch sorry if messy, onty had 3 days
thanks!
(sorry dont know how add sketch properly)
int ledpin1 = 5;
int ledpin2 = 7;
void setup() {
pinmode(ledpin1, output);
pinmode(ledpin2, output);
}
void loop()
{
int ledpin1value = digitalread(ledpin1);
digitalwrite(ledpin1, high);
delay(1000);
digitalwrite(ledpin1, low);
delay(1000);
if (ledpin1value = high) {
digitalwrite(ledpin2, low);
}
else {
digitalwrite(ledpin2, high);
}
}

ive been going through beginner tutorials , sketches , learning basics, started learning 'if' statements , thought try , use 1 turn 2 led's 1 , off modifying blink example, example had 1 led running normal blink used second led in if statement opposite of led 1 does. reason wont work, obvious, led 1 blinks fine led 2 stays off. ill add sketch sorry if messy, onty had 3 days
thanks!
(sorry dont know how add sketch properly)
int ledpin1 = 5;
int ledpin2 = 7;
void setup() {
pinmode(ledpin1, output);
pinmode(ledpin2, output);
}
void loop()
{
int ledpin1value = digitalread(ledpin1);
digitalwrite(ledpin1, high);
delay(1000);
digitalwrite(ledpin1, low);
delay(1000);
if (ledpin1value = high) {
digitalwrite(ledpin2, low);
}
else {
digitalwrite(ledpin2, high);
}
}
i understand trying buts allot easier this.
btw code added using # button in message edit field.
but problem code need '==' not 1 '='.
btw code added using # button in message edit field.
code: [select]
int ledpin1 = 5;
int ledpin2 = 7;
void setup() {
pinmode(ledpin1, output);
pinmode(ledpin2, output);
}
void loop()
{
int ledpin1value = digitalread(ledpin1);
digitalwrite(ledpin1, high);
digitalwrite(ledpin2, low);
delay(1000);
digitalwrite(ledpin1, low);
digitalwrite(ledpin2, high);
delay(1000);
}but problem code need '==' not 1 '='.
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Newbie :) 'if' help
arduino
Comments
Post a Comment