criticalmaking.com

Voters Beware!! Part 3

February 11, 2009inf2241_classfi22410

Today team shake-n-bake completed our biased voting machine. What fun! We accomplished a lot in this particular lab experience, mainly integrating processing with arduino. Our problems from last week were resolved (we were able to get input from two separate pushbuttons). For the first part of the lab, we fandangled with the serial input from the pushbuttons until we were able to get a distinct input from each button in the arduino software. Translating this ability to the processing sketch took some more work but thanks to the diligent efforts of our code expert, we were able to rework the code from a ‘processing meets arduino’ pushbutton example we found online.

We added a function in our code which would count the number of times each button was pressed. We decided to hide this function from the user of the voting machine, to bring forth the idea that electronic voting machines do not allow the user to verify that they have voted correctly. Instead, this count was outputted to a txt file, where the votes for each button were tabulated. We then developed a series of questions to vote on, based on preferences of ice cream flavours (a built-in bias against the lactose intolerant and vegans). At first, we worked on getting the questions to appear in sequence, then we made each following question appear only after the first question was voted on. At this point, we discovered that the delay built into the button presented another bias. If the delay was too small (initially 1/10th of a second), the questions would all appear if the button was pressed too long. We extended the delay, but found it to be too long. Finding an intuitive length of time that is appropriate for pushing the button was difficult. Matt revealed the bias of this aspect of our voting machine when he pressed the button too long during the demo and ran through the list of questions too quickly.

Overall, the team found this to be a great learning experience in terms of becoming aware of the many biases that can occur at various levels of the design process. Though the main bias informing our design was a cultural bias as to the meanings associated with colours (red=no, green=yes), we found that other biases were present and were noted as we became aware of their potential presence. The button delay in the code is an example of this.

Below is the code for Processing, which outputs five questions to the voter. When the voter pushes either the the yes or no button (without holding the button down longer that .250 seconds, which was a biased assumption during the design phase as mentioned above), the next question will appear. After the five questions have been answered, the program outputs a ‘complete status’ message, writes the voting results to a text file, and exits from the program.

/*
* Voters Beware! Pt3
* By Nancy, Marta, and Mike
* Description: This program will output series of questions to user and * wait to receive Yes/No reponse, before outputting next question. When * series of questions are complete, program writes tally to text file
*/

// importing the processing serial class
import processing.serial.*;

// variables for serial connection, portname and baudrate have to be set
Serial port;
String portname = “/dev/ttyUSB0″; //”/dev/cu.usbserial-1B1”;
int baudrate = 9600;
int value = 0;

// count variables
int count_y = 0;
int count_n = 0;

//other variables
String[] questions = new String[5];
int arr_counter = 0;
PrintWriter output;

void setup(){

// initialize port
port = new Serial(this, portname, baudrate);

// set path for text file
output = createWriter(“/home/criticalmaking/Desktop/Shake-n-Bake/Voting_System/votes.txt”);

// load questions into array
questions[0] = “Do you prefer chocolate to vanilla ice cream?”;
questions[1] = “Do you prefer vanilla to strawberry ice cream?”;
questions[2] = “Do you prefer mint chocolate chip to vanilla ice cream?”;
questions[3] = “Do you prefer pistachio to rocky road ice cream?”;
questions[4] = “Do you prefer corn & cheese ice cream to butterscotch ice cream?”;

// show the first question
println(questions[0]);
}

// this function handles the serial input
void serialEvent(int serial){

// yes response
if(serial==’Y’) {
println(“”);
count_y++;
arr_counter++;
}
// no response
else if(serial==’N’){
println(“”);
count_n++;
arr_counter++;
}

// show questions until end of array is reached
if(arr_counter<5){
if(serial==’Y’ || serial==’N’) {
println(questions[arr_counter]);
}
}

// when questions are done, output indication, write results to file and // exit
if((serial==’Y’ || serial==’N’) && arr_counter>=5) {
println(“That’s it! No more questions. Enjoy your dairy products!”);

output.println(“Yes:” + count_y + “No:” + count_n);
output.flush(); // Writes the remaining data to the file
output.close(); // Finishes the file
exit();

}

}

void draw(){

// listen to serial port and trigger serial event
while(port.available() > 0){
value = port.read();
serialEvent(value);
}
}

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