help need help programming arduino to do certain commands for project

I need the Arduino to turn on with the push button then allow me to change the brightness of it. For example, with the push button i turn on the led and it stays on. Then after I turn it on I would want it to allow me to change the brightness of it by using a potentiometer. I did the following code but it said in the Arduino " ^ exit status 1 expected unqualified-id before '{' token " I would please prefer to have an answer by June 2, 2018 or before please. and thank you for reading. I really THANK YOU.


define led 9

define knob 0

int pushbuttonPin = 4; int val = 0; int lightON = 0; int pushed = 0;

void setup(){ Serial.begin (9600); pinMode(pushbuttonPin,INPUT); delay(100); }

{ pinMode(led, OUTPUT); } void loop(){ val = digitalRead(pushbuttonPin); if(val == HIGH && lightON == LOW){ pushed = 1-pushed; delay(100); } lightON = val; if(pushed == HIGH){ Serialprint.ln("Light ON"); }else{ Serial.println("Light OFF"); } delay(100); { int val = analogRead(knob); val = map(val, 1, 1024, 1, 255); analogWrite(led, val); }


 pinMode(led, OUTPUT);

The commented brackets are strays and cause some error(s).

Serialprint.ln("Light ON");

Dot in the wrong place.

 int val = analogRead(knob);

Another stray bracket

Please read the "how to use the forum-please read" stickies.

add } to the last line

It is also fortunate that the current definition of HIGH is 1 and the current definition of LOW is 0.