I have an Arcade Machiene that I have made, and I wanted to get all fancy and do some things with an arduino, I have planned to interface some rgb strips etc later, but for now I have it setup with three switches on a control panel that are wired to the arduino. the idea of the switches is to control the tv but also allow multiple functions on the same switch.
The switches are defined in the code as:
//switches on the front panel conencteed to these pins, pulled to low when pressed.
int up = 5;
int power = 4;
int down = 6;
The code is my attempt at a state machiene, using simple 1 and 0 flags to trigger events in non blocking code.
The power button is basically debounced, and then toggles the tv power on or off if held for more than 3 seconds,
during the run up to those 3 seconds it acts as a "shift" button allowing secondary functions to be achieved by pressing the up and down buttons,
there are four relays connected to the arduino are represented in the code by out1 to out4, the relays always do as expected when expected. (apart from needing to reverse the logic to trigger them)
there are then three wires soldered to the TV push buttons for power and volume up and down.
when i want to trigger a button press i briefly set them as outputs then back to inputs,
so the conundrum I would like some help with is:
the volume doesnt work as expected when first powered up.
the volume up actually reduces the volume, and the vol down apparently does nothing, the power button works as expected, and when power is used as shift, both up and down vol buttons activate the relays.
there is a lot of serial debugging in the code, which suggests to me that the output to the tv has been toggled as expected but the TV doesnt react.
THEN
once I power cycle the TV by holding the power button 3 seconds, waiting briefly then doing it again, then the vol buttons react as expected for as long as the arduino stays powered up.
once I reset power to the arduino it all goes pants again.
I have gone through the code time and time again, looking for flags that are not set, or double set, but my serial debugging is oly sent right as the output is sent to the TV, so if i can read it, then it shoudl have been sent,
I cant for the life of me work out whats going on.
any help would be greatly appreciated, Ive done my best to annotate the code and give it meaningful names, so hopefully it can be understood.
m00se
cabinet_2.2_keypad_lockout.ino (11.9 KB)