Go Down

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


Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0


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


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;

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.
The art of getting good answers lies in asking good questions.

Go Up