Hey everybody, this is one of my first posts here but I've been hawking the forums for a long while now.
I am an electronic engineering technician coming up on graduation. I have been working on my final project here and have most of the fine details worked out. I'm looking for some guidance in the coding structure if anybody has any thoughts or ideas and some time. I don't need somebody to walk me through step by step -- but I am making some sort of mistake here that I need assistance correcting. So I'll try to provide as much detail pertaining to my project as I possibly can so you can get the big picture here.
What I am constructing is a 2 axis servo control for a camera. I hope to apply this either as either a home security system OR as a FPV for an rc car/plane. I've got a pan/tilt module with 2 servos -- 1 for each axis. I also have 3 normally open, press button switches -- that I wish to use to select the "state" in which I will be reading the inputs.
I wish to have state 1 select free look using a 2-pot thumbstick.
I wish to have state 2 LOCK the thumbstick values and continuously pulse the servos according to what the joystick reads at the time of selecting pressbutton 2.
Lastly I wish to have button state 3 reserved as an automated sweep in which I will have a series of pulses to each servo -- guiding the camera to sweep the field of site back and forth automatically.
Essentially, I am trying to establish a structure in which there are 3 conditions. Depending on which pressbutton is activated, I wish to store into a variable either a 0,1, 2, or 3 -- which I hope to then say:
"while variable = 0; do nothing"
"while variable = 1; free look using thumbstick"
"while variable = 2; lock servos in place"
"while variable = 3; automatically sweep"
So I am also multiplexing a tri-color LED to represent which condition is running (red = lock, green = sweep, blue = free look).
When no pressbutton = HI, variable = 0 and do nothing.
When pressbutton 1 = HI, variable = 1, run subroutine 1 (free look)
When pressbutton 2 = HI, variable = 2, run subroutine 2 (lock)
When pressbutton 3 = HI, variable = 3, run subroutine 3 (sweep)
This is the essential goal I am aiming for. I am having trouble initializing the outputs to a specific state. I need my LED outputs to initialize to the HIGH condition (because they are common cathodes and I require a LOW to turn them on).
I also tried using If statements as well as While statements to set up the parameters for each subroutine. But it seems as if "variable" is not changing when I temporarily close any of the selected pressbutton switches. I am trying to upload a basic block diagram depicting the structure I am aiming for. Hopefully this helps visualize my goal.
Any input on how to set up the structure for which I can build upon -- would be greatly appreciated. Even a few pointers to get my in started in the right direction would suffice.
I appreciate you guys taking the time to read through and give me a hand here. MUCH appreciated. Thanks you guys -- I look forward to some responses and getting some positive progress made here!
