Whatsup. New on Arduino. Im trying to write a sketch that reads the distance from the ultrasonic sensor and turns on an led depending on the distance.... I get this issue...
IfTestCode:21:1: error: expected unqualified-id before 'if'
if (Distance >= 70) {
^
IfTestCode:26:1: error: expected unqualified-id before 'else'
else {
^
exit status 1
expected unqualified-id before 'if'
Here is my code.....
const int Ledpin = 8; #include "SR04.h" #define TRIG_PIN 12 #define ECHO_PIN 11
SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
long a;
Thank you for responding so fast Larry! Would It be possible for you to show me what you mean? I tried what you suggested with no avail. Thanks a bunch!
The error I receive now is that its not recognizing the second half of the code. Here it is
In function 'void loop()':
IfTestCode:22:16: error: 'LedPin' was not declared in this scope
digitalWrite(LedPin, HIGH);
^
IfTestCode:26:16: error: 'LedPin' was not declared in this scope
digitalWrite(LedPin, LOW);
^
exit status 1
'LedPin' was not declared in this scope