Hey guys,
ive been searching for quite a while and cant come up with a reason that I keep getting errors with this code. I’ve got some explanation inside the code of what im trying to acomplish. I keep getting
expected primary-expression before ‘||’ token
or
expected ‘)’ before ‘;’ token
depending on what I do to try and remedy the other issues.
int fan = 2;
int switchpin = 3;
int led1 = 4;
int led2 = 6;
int led3 = 9;
int led4 = 10;
int sensorpin = A0; //potentiometer
int fanspeed = 255;
int brightness1 = 0;
int brightness2 = 0;
int brightness3 = 0;
int brightness4 = 0;
void setup() {
// put your setup code here, to run once:
pinMode(fan, OUTPUT);
pinMode(switchpin, INPUT_PULLUP);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//if potentiometer reads ~50% or more then turn led 4 on and turn the fan onto full speed
if (analogRead(sensorpin) >= || == 500) {
digitalWrite(led4, HIGH);
analogWrite(fan, 255);
}
//if button is low turn all leds on high
else if (analogRead(switchpin) == LOW){
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
}
// if button is low and potentiometer reads less then or equal to ~ 49%
//fade all lights in sequence
if (analogRead(switchpin) == LOW && analogRead(sensorpin) <= || == 499) {
digitalWrite(led1, HIGH);
delay(1000);
digitalWrite(led1, LOW);
(brightness2 = 255; brightness2 >=0; brightness2 -= 3)
analogWrite(led2, brightness2);
delay(30);
(brightness3 = 255; brightness3 >=0; brightness3 -= 3)
analogWrite(led3, brightness3);
delay(30);
() (brightness4 = 255; brightness4 >=0; brightness4 -= 3)
analogWrite(led4, brightness4);
delay(30);
}
// in all other occasions
else (analogRead(switchpin) == HIGH){
digitalWrite(led1, HIGH);
delay(300);
digitalWrite(led1, LOW);
delay(300);
digitalWrite(led2, HIGH);
delay(300);
digitalWrite(led2, LOW);
delay(300);
digitalWrite(led3, HIGH);
delay(300);
digitalWrite(led3, LOW);
delay(300);
digitalWrite(led4, HIGH);
delay(300);
digitalWrite(led4, LOW);
}
}
also, is anyone aware of any site or video that really dumbs down what all the functions and terms mean? I have a basic understanding, but when I try to figure out some of the more advanced stuff i get kinda confused. the reference and language page are not written in laymens terms and most other pages i can find go over the very basic stuff that i already have done or know.
THANKS!!!