Go Down

Topic: How to fix my sketch (Read 1 time) previous topic - next topic


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



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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up