So.. My project is this. Use the barometer and a 3 axis gyro together to make an aircraft stabilization system. Flipping my switch will start a program that will take the x, y, z values from the gyro, and values from the barometer and hold it steady there. My question to you people is, can i flip a switch on my controller, use that as an input for my arduino? That I know i can do, but with that input, can i somehow pause and resume a batch of code? (the stabilizing code).
I think that i'm going to have to use interrupts, like flip the switch, it interrupts the program, the program stops working, and when i flip it again the program resumes, takes data values again and starts stabilizing. Is it possible?
Im looking for some sample code right now that interrupt whenever i move the sticks to control the aircraft, so maybe the same principle can be used for the switches.
I don't imagine there will be any need for interrupts.
Imagine that you code includes 2 functions one of which runs normally and the other runs when you send a special signal. Then all you need is code to detect the signal (perhaps just digitalRead() ) and select the appropriate function. Maybe like this
I have a three position switch that i'd like to use. Would i have to run two If Else statements, with the else being the same on both, or is it possible for me to write two If's and one Else?
Sorry about my lack of knowledge on arduino code, it's just that i'm in a time crunch. I've started to read your thread on planning and implementing a program.