Go Down

Topic: Servo Control with three buttons. (resolved and working!!!) (Read 1 time) previous topic - next topic

JimboZA

meArm build blog:     http://jimbozamearm.blogspot.com/

icecats

Yes, it will be a few days, but I will try to send/post you a video/pictures of some sort.

PaulS

I'm happy that you have it working, but there are a couple of points I'd like to make.
Code: [Select]
int armed = false;
That's not a boolean.

Code: [Select]
boolean armed = false;
is.

Code: [Select]
  if (BState == HIGH && armed == true){
BState == HIGH evaluates to true if BState contains HIGH. armed == true evaluates to true if, and only if, armed contains true. Since the contents of armed are equal to the result returned by the == operator, the == true bit is unnecessary. This would be written:
Code: [Select]
  if (BState == HIGH && armed)
  {


The magic numbers used to define where the servo moves to should be #define'd, so that the positions have names. It makes it a lot easier to understand the code later.

1000 milliseconds is a LONG time to dispense salt or pepper, no matter how bland the food. That magic number should be #define'd, too.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy