I have corrected many obvious mistakes in my coding but I'm unable to fathom this one. Any advice please.
int myPin = A2;
int readVal;
float V2;
int redPin = 4;
int yellowPin = 3;
int greenPin = 2;
void setup() {
Serial.begin(9600);
pinMode(myPin, INPUT);
pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
readVal = analogRead(myPin);
V2 = (5. / 1023.) * readVal;
Serial.print("Potentiometer Voltage equals ");
Serial.println(V2);
}
If (V2 < 3.0) {
digitalWrite(greenPin, HIGH);
}
If (V2 > 3.0) {
digitalWrite(greenPin, LOW);
}
If (V2 > 3.0 || < 4.0) {
digitalWrite(yellowPin, HIGH);
}
If (V2 < 3.0 || > 4.0) {
digitalWrite(yellowPin, LOW);
}
If (V2 > 4.0) {
digitalWrite(redPin, HIGH);
}
If (V2 < 4.0) {
digitalWrite(redPin, LOW);
}
...and here are the error messages;-
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"
IF_Assignment:23:4: error: expected constructor, destructor, or type conversion before '(' token
If (V2 < 3.0) {
^
IF_Assignment:26:4: error: expected constructor, destructor, or type conversion before '(' token
If (V2 > 3.0) {
^
IF_Assignment:31:4: error: expected constructor, destructor, or type conversion before '(' token
If (V2 > 3.0 || < 4.0) {
^
IF_Assignment:35:4: error: expected constructor, destructor, or type conversion before '(' token
If (V2 < 3.0 || > 4.0) {
^
IF_Assignment:39:4: error: expected constructor, destructor, or type conversion before '(' token
If (V2 > 4.0) {
^
IF_Assignment:43:4: error: expected constructor, destructor, or type conversion before '(' token
If (V2 < 4.0) {
^
exit status 1
expected constructor, destructor, or type conversion before '(' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.