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

I'm keen to see it in action
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Newbie
*
Karma: 1
Posts: 17
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: 652
Posts: 50868
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: