Hi i'm new to Arduino and i really need help
void setup(){
digitalWrite(12,OUTPUT);
}
void loop(){
int Number=random(1-2);
if (Number)=(1);
digitalWrite(12,HIGH);
}
Hi i'm new to Arduino and i really need help
void setup(){
digitalWrite(12,OUTPUT);
}
void loop(){
int Number=random(1-2);
if (Number)=(1);
digitalWrite(12,HIGH);
}
Welcome to the forum
if (Number)=(1);
= to assign a value to a variable
== to compare a variable to a value
and the brackets are in the wrong place
and the semicolon should not be there
and the random() function has the wrong parameters
could you like show me how the code would be correct?
void setup()
{
digitalWrite(12, OUTPUT);
}
void loop()
{
int Number = random(1, 3); //random number, either 1 or 2
if (Number == 1)
{
digitalWrite(12, HIGH);
}
}
Note that once on the LED will not turn off
void setup()
{
digitalWrite(12, OUTPUT);
}
Shouldn't that be
void setup()
{
pinMode(12, OUTPUT);
}
OMFG im so stupid. Thanks for the help
You're welcome. Simple mistakes happen to all of us at one time or another.