Same code is working when not used as part of a function. Any ideas why? Currently using tinkercad to simulate as I'm not near my hardware at the moment incase that's related.
P.S very inefficient, yes, but that's a problem for later.
// pin declaration
// flood lighting
const int LEFT_FLOOD = 10;
const int FRONT_FLOOD = 3;
const int RIGHT_FLOOD = 4;
// emergency lighting
const int FRNT = 5;
const int REAR = A0;
const int FULL_LIGHTING = 6;
// misc
const int SRN = 7;
const int ALERT = 8;
const int CLR = 9;
// status bools
bool leftfldon = false;
bool frontfldon = false;
bool rightgldon = false;
bool frnton = false;
bool rearon = false;
bool fullon = false;
bool srnon = false;
bool alrton = false;
bool clron = false;
// read ints
int leftfld = 0;
int rightfld = 0;
int frontfld = 0;
int frnt = 0;
int rear = 0;
int full = 0;
int srn = 0;
int alert = 0;
int clr = 0;
// custom functions
bool checkButtonStatus(int thing, bool thing2) {
if (thing == HIGH){
thing2 = !thing2;
Serial.println(thing2);
delay(450);
}
}
void setup()
{
pinMode(LEFT_FLOOD, INPUT);
pinMode(FRONT_FLOOD, INPUT);
pinMode(RIGHT_FLOOD, INPUT);
pinMode(FRNT, INPUT);
pinMode(REAR, INPUT);
pinMode(FULL_LIGHTING, INPUT);
pinMode(SRN, INPUT);
pinMode(ALERT, INPUT);
pinMode(CLR, INPUT);
Serial.begin(9600);
}
void loop()
{
delay(75);
leftfld = digitalRead(LEFT_FLOOD);
rightfld = digitalRead(RIGHT_FLOOD);
frontfld = digitalRead(FRONT_FLOOD);
frnt = digitalRead(FRNT);
rear = digitalRead(REAR);
full = digitalRead(FULL_LIGHTING);
srn = digitalRead(SRN);
alert = digitalRead(ALERT);
clr = digitalRead(CLR);
checkButtonStatus(leftfld, leftfldon);
}