Hi, I have only recently started to learn how to code this Arduino processor for the purpose of building a solar tracker. I am using an Arduino Uno revision 3, the error is located where I marked error here and the error message is:
Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\Tommy\Documents\Arduino\sketch_oct28b\sketch_oct28b.ino: In function 'void loop()':
sketch_oct28b:28:29: error: expected primary-expression before '>=' token
while (servoSet <=140 && >=15) { // if so, send panels back to east for the sunrise
^
exit status 1
expected primary-expression before '>=' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
My code is:
#include <Servo.h>
Servo servo; // Create a servo object to control the servo
int eLDRPin = A0; // Assign pins to the LDR's
int wLDRPin = A1;
int eastLDR = 0; //Create variables to store to LDR readings
int westLDR = 0;
int difference = 0; //Create a variable to compare the two LDR's
int error = 10; // Variable for is there is a noticable difference between the tow LDR's
int servoSet = 130; //Variable for position of servo - will be different for each device
void setup() {
servo.attach(9); //attaches the servo object to PWM pin 9
Serial.begin(9600);
}
void loop() {
eastLDR = analogRead(eLDRPin); //Read the LDR values
westLDR = analogRead(wLDRPin);
if (eastLDR < 400 && westLDR < 400) { //Check to see if there is low light on both LDR's
while (servoSet <=140 && >=15) { // if so, send panels back to east for the sunrise //*error here*
servoSet ++;
servo.write(servoSet);
delay(100);
}
}
difference = eastLDR - westLDR ; //Check the difference
if (difference > 10) { //Send the panel towards the LDR with a higher reading
if (servoSet <= 140) {
servoSet ++;
servo.write(servoSet);
}
} else if (difference < -10) {
if (servoSet >= 15) {
servoSet --;
servo.write(servoSet);
}
}
Serial.print(eastLDR); //Serial monitor can be useful for debugging/setting up
Serial.print(" - "); //Use it to see if your LDR's are noticeably different when
Serial.print(westLDR); //They have equal light shining on them, if so, correct with the error value
Serial.print(" - ");
Serial.print(difference);
Serial.print(" - ");
Serial.print(servoSet); //Fine tune the servo settings, to maximise swing available
Serial.print(" - ");
Serial.println(".");
delay(100);}
Any help would be greatly appreciated!