Go Down

Topic: Error Compiling  (Read 1 time) previous topic - next topic

CoderDoggie

I am 13 and quite new to Arduino programming. I have just finished programming a project for my Arduino Uno. It is meant to be a bike indicator. Except, when I tried verifying it when I fixed all of the errors, it keeps saying 'Error Compiling'. I have tried uploading other projects to my board and they still work yet JUST this one doesn't. Is there something wrong with my code? Here is my code:

int lButton = 3;
int rButton = 2;
int lLed = 4;
int rLed = 5;
int lButtonState = 0;
int rButtonState = 0;

void setup()
{
  pinMode(lButton, INPUT);
  pinMode(rButton, INPUT);
  pinMode(lLed, OUTPUT);
  pinMode(rLed, OUTPUT);
}
 
void check()
{
  lButtonState = digitalRead(lButton);
  rButtonState = digitalRead(rButton);
  if(lButtonState == HIGH || rButtonState == HIGH)
  {
    if(lButtonState == HIGH && rButtonState == HIGH)
    {
      digitalWrite(lLed, HIGH);
      digitalWrite(rLed, HIGH);
    }
    else if(lButtonState == HIGH)
    {
      digitalWrite(lLed, HIGH);
    }
    else
    {
      digitalWrite(rLed, HIGH);
    }
  }
}

Or is there something wrong with the program? Here is the error message:

Arduino: 1.6.6 (Mac OS X), Board: "Arduino/Genuino Uno"

core/core.a(main.cpp.o): In function `main':
/Users/tirdadtaherian/Desktop/Documents/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/main.cpp:46: undefined reference to `loop'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Please help as this is a project I have been thinking of making for a while now and it is very useful for me. Thanks. :).



codlink

Code: [Select]
void check()
Should be
Code: [Select]
void loop()
Not sure how you got "check" in there...

You also have one too many ending '}'.
//LiNK

CoderDoggie

Thank you so much. The reason why I had 'check' instead of loop is because I used a code from someone else's but they already had loop before 'check'.
Thank you so much.

Go Up