We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I have a project that I made and the first code is like controlling a servo manually and the 2nd code is to control a servo automatically, now the problem is that I have tried to combine both codes into one code and make an if statement to choose if I want to control the servo manually or automatically.
I tried to input a key like this
void keyPressed() {
if (key = '1') {
mode = key ;
}
else if (key = '2') {
mode = key ;
}
}
and I put this code right after void draw
if (mode = '1'){*the manual control code}
else if(mode = '2'){*the auto control code*}t
I do not know how to convert this if statement to GUI too as I do need this too.
I just need to know where should I put the if statement (if statement is easier than button GUI I think..)
PS: my main project is sentry gun and I can control it manually via mouse or automatically via camera (tracking).
I hope you guys get this.
Thank You
Answers
Format your code for the forums. Select it and press the C button above the text entry box.
The error you are getting seems to indicate that you have mis-matched braces - maybe void draw should be void draw(){ ? Press Ctrl-t in the Processing editor to format your code.
here it is but it wont work without an arduino.. this is the 2 codes (inside if (mode=...etc) statement )I want to make a key to chose between them
ps: I chose your answer as "Accepted Answer" I thought it was making me allow your question to be posted here.. ^^
I have edited the void update() to this and put it in the end outside of the if statement ps:I replaced all Mx and My to x and y
= is assignment. == is comparison test.
sorry I did not get you? I am sort of a beginner in processing
Same thing I've posted at:
http://forum.processing.org/two/discussion/4332/how-to-access-library-functions-from-within-the-draw-method-themidibus
O.O it worked! thank you so much GoToLoop and TfGuy44! you saved me "Equality operator == is not the same as assignment operator"