Arduino Forum

Products => The Arduino Starter Kit and Basic Kit => Topic started by: Mandela01 on Feb 23, 2014, 01:11 am

Title: How to fix my sketch
Post by: Mandela01 on Feb 23, 2014, 01:11 am
Can anyone help me fix my sketch it keeps on saying ecpected to be at the end of input}
// Fading Light with button
const int LED = 9; // the pin for the LED
int i = 0; //usedbto count up and down
const int BUTTON = 7;
int val =0; //val will be used to store the state of the input pin
void setup() {
  pinMode(LED, OUTPUT); //LED is a output
  pinMode(BUTTON, INPUT); // and BUTTON is an INPUT
}
void loop()
{
  val = digitalRead(BUTTON);//read input value and store it
  //check whether the input is HIGH (button pressed)
  if (val == HIGH) {
    digitalWrite(LED, HIGH); //turn LED on
  } else {
    digitalWrite(LED, LOW);
  }
  {
  for (i + 0; i < 255; i++) { // loop from 0 to 254 (fade in)
    analogWrite(LED, i); // set the LED brightness
    delay(10); // waits 10ms
  }
  for (i = 255; i > 0; i--){ // loop from 255 to 1 (fade out)
    analogWrite(LED, i); // set the LED brightness
    delay(10);} //wait 10ms
  }

Thankyou
Title: Re: How to fix my sketch
Post by: CrossRoads on Feb 23, 2014, 06:01 am
You need one more } at the end of the code to finish up void loop.

If you use CTRL-T, it will tell you that there is one missing.