Hi all,
In the interest of your time, here's the tldr version:
I don't want to define all the variables during the setup, so I want to be able to do so on a per need basis during the loop. All is going well until this expression:
if (bool f3 == 0) {
...
}
Where I get this error: expected primary-expression before 'bool'
Here's all of my code:
#define CLKPin 6
#define DTPin 7
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd (0x27, 16, 2);
bool CLKCurrentState;
bool DTCurrentState;
bool CLKPreviousState;
int genericCounter = 0;
int MM = 0;
int buttonPin = 8;
bool buttonState = 1;
int genericCounterCorrected;
void setup () {
pinMode (CLKPin, INPUT);
pinMode (DTPin, INPUT);
pinMode (buttonPin, INPUT);
CLKPreviousState = digitalRead (CLKPin);
lcd.init ();
lcd.backlight ();
Serial.begin (9600);
}
void loop () {
bool f1 = 0;
while (f1 == 0) {
bool f2 = 0;
while (f2 == 0) {
CLKCurrentState = digitalRead (CLKPin);
if (CLKCurrentState != CLKPreviousState) {
if (digitalRead (DTPin) == CLKCurrentState) {
genericCounter--;
} else {
genericCounter++;
};
};
CLKPreviousState = CLKCurrentState;
if (genericCounter != 0 && genericCounter % 2 == 0) {
f2 = 1;
};
buttonState = digitalRead (buttonPin);
if (buttonState == 0) {
bool f3 = 1;
f1 = 1;
}
};
if (bool f3 == 0) {
genericCounterCorrected = genericCounter / 2;
MM = MM + genericCounterCorrected;
genericCounter = 0;
if (MM >= 32) {
MM = 1;
} else if (MM <= 0) {
MM = 31;
};
}
bool f3 = 0;
int onesF = MM % 10;
int tensF = ((MM - onesF) % 100) / 10;
int hundredsF = ((MM - onesF - tensF) % 1000) / 100;
int thousandsF = ((MM - onesF - tensF - hundredsF) % 10000) / 1000;
lcd.setCursor (0, 0);
lcd.print (tensF);
lcd.setCursor (1, 0);
lcd.print (onesF);
}
}
is there a way to do so?