"expected ( before 'Input' "

I'm trying to get an LED to light up from pressing and holding a button down, this code is written from what I've learned so far. I'm really new to this and this is the best I could do.
Here's the code:

int Input = 1;
void setup() {
// put your setup code here, to run once:
pinMode(12,INPUT);
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
}

void loop() {
// put your main code here, to run repeatedly:
if Input = 0
digitalWrite(13,HIGH);
if Input = 1
digitalWrite(13,LOW);
}

"expected ( before 'Input' "

Check the syntax of the if statement as used in C

Actually two mistakes, only one of which was picked up by the compiler, the other will never be. :roll_eyes:

And, I hope you’re not planning to use Serial Monitor later.

@ello, please edit your post, select all code and click the </> button to apply code tags. Next save your post.

Search for arduino/reference! That's a gold mine for everybody, sooner or later.

If ( input ==0)
{ etc
}

Hi,
Did you Google;

arduino led button example

Look at this link.
https://create.arduino.cc/projecthub/SBR/working-with-an-led-and-a-push-button-71d8c1

Tom... :smiley: :+1: :coffee: :australia:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.