criticalmaking.com

Voters beware!! Pt 2

February 11, 2009inf2241_classfi22410

We have settled on the design for our Voters Beware machine, and completed most of the wiring and programming.  Presently, our device has two buttons, one indicating yes and the other no (which are also color coded).

If you push the yes button, an LED will light up to signal you have pressed it, and the serial monitor on the computer will output “Y”.  If you push the no button, the same LED will light up and “N” will be output to the serial monitor.   We had some struggles at the end of the class trying to get the logic sorted out in our programming, but we were able to figure out the issue, which allows next week to focus on Processing and putting the final touches on the device.

Below is the Arduino code for our voting machine:

/*
Voting Machine
Last updated Feb 4, 2009
Critical Making
Team Shake-n-Bake (Nancy, Marta, and Michael)
*/

// variables for input pin and control LED
int button_yes = 7;
int button_no = 6;
int LEDpin = 13;

// variable to store the value
int value_yes = 0;
int value_no = 0;

void setup(){

// declaration pin modes
pinMode(button_yes, INPUT);
pinMode(button_no, INPUT);
pinMode(LEDpin, OUTPUT);

// begin sending over serial port
beginSerial(9600);
}

void loop(){
// read the value on digital input
value_yes = digitalRead(button_yes);
value_no = digitalRead(button_no);

// write this value to the control LED pin
if (value_yes)
digitalWrite(LEDpin, value_yes);
else if (value_no)
digitalWrite(LEDpin, value_no);
else
digitalWrite(LEDpin, LOW);

// if value is high then send the letter ‘H’ else send ‘L’ for low
if(value_yes)
serialWrite(‘Y’);
else if(value_no)
serialWrite(‘N’);
else
serialWrite(‘-‘);

// wait a bit to not overload the port
delay(100);
}

You can follow any responses to this entry through the RSS feed. You can leave a response, or trackback from your own site.

Leave a reply

Follow Us