Pages: 1 2 [3]   Go Down
Author Topic: Servo Control with three buttons. (resolved and working!!!)  (Read 335 times)
0 Members and 1 Guest are viewing this topic.
Johannesburg UTC+2
Offline Offline
Faraday Member
**
Karma: 60
Posts: 3242
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm keen to see it in action
Logged

Have you looked for answers in the Learning, Reference, Products and Playground tabs on http://arduino.cc/en/ ?
Look here http://electronicsclub.info/ for basic electronics

Offline Offline
Newbie
*
Karma: 1
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 45982
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
boolean armed = false;
is.

Code:
  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:
  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.
Logged

Pages: 1 2 [3]   Go Up
Jump to: