Hello just wrote alot of code and debbuged it but this one thing dosent wors anyway here is the code:
int First_Digit = 2;
int Second_Digit = 3;
int Third_Digit = 4;
int a = 5;
int b = 6;
int c = 7;
int d = 8;
int e = 9;
int f = 10;
int g = 11;
int Fan_Out = 12;
const int Up_Button = A0;
const int Down_Button = A1;
//Variables
int Fan_Speed = 0;
int Button_Up_Preses = 0; // current reading
int Button_Down_Preses = 0; // current reading
unsigned long lastDebunceTime_Button_Up = 0; //last time the pin was changed
unsigned long lastDebunceTime_Button_Down = 0; //last time the pin was changed
unsigned long debunceDelay = 100; //Increse or decrese to fine tune
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//Int Pins
pinMode(First_Digit, OUTPUT);
pinMode(Second_Digit, OUTPUT);
pinMode(Third_Digit, OUTPUT);
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(Fan_Out, OUTPUT);
pinMode(Up_Button, INPUT);
pinMode(Down_Button, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int Button_Up_Preses = analogRead(Up_Button);
int Button_Down_Preses = analogRead(Down_Button);
}
if(((millis() - lastDebunceTime_Button_Up) > debunceDelay) && (Fan_Speed < 100)) {
// if( (Button_Up_Preses >= 950) && (Fan_Speed < 100))
Fan_Speed += 5;
}
else {
Fan_Speed = Fan_Speed;
}
if((Button_Down_Preses >= 950) && (Fan_Speed > 0)) {
Fan_Speed += -5;
}
else {
Fan_Speed = Fan_Speed;
}
if(Button_Up == 5) {
digitalWrite(First_Digit, HIGH);
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, HIGH);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
digitalWrite(First_Digit, LOW);
}
else if(Fan_Speed == 10)
{
digitalWrite(First_Digit, HIGH);
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
delay(1);
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
digitalWrite(First_Digit, LOW);
delay(1);
digitalWrite(Second_Digit, HIGH);
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, HIGH);
delay(1);
digitalWrite(Second_Digit, LOW);
}
else
{
digitalWrite(First_Digit, HIGH);
digitalWrite(Second_Digit, LOW);
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, HIGH);
}
Serial.print(" Fan Speed = ");
Serial.print (Fan_Speed);
Serial.println();
delay(15);
}
Told you its long and not finshied
Its used with 2 buttons and 7segment 4 character dispaly
I'm havin issuse with this line
[/right]if(Fan_Speed == 5) {
Its in the middle of the loop section
Its giving me the error expected unqualified id before if
Please help