Go Down

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

JimboZA

Arduino ethernet server here.... http://jimboza.gotdns.com:8085/

No PMs for help please

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