Description
Using two DC motors and a belt, we constructed a game to teach young children left and right. A Processing application sends a code to the belt to vibrate the left or right motor, then the player chooses which motor vibrated. The selectors are placed vertically on the screen so the only mapping is linguistic. Choosing correctly raises the score; incorrectly lowers it.
Components used
Arduino diecimila
Breadboard
Two DC motors
Two transistors
Two diodes
Two AA batteries
Hemp belt
Arduino code
/*
* LRbelt
* Andrew McDiarmid
*
* Receives a byte of serial data, either 'R' or 'L', ans spins
* the appropriate motor on a belt worn by the user.
*
* Accompanying Processing code controls bytes sent to arduino
*/
int rightMotorPin = 6;
int leftMotorPin = 9;
char sideToVibrate;
void setup() {
Serial.begin(9600);
digitalWrite(rightMotorPin, LOW);
digitalWrite(leftMotorPin, LOW);
Serial.print("go"); //Tell Processing "I'm ready."
}
void loop() {
if(!Serial.available()) {
return;
} else {
sideToVibrate = (char) Serial.read();
}
if (sideToVibrate == 'R'){
for (int i = 0; i < 256; i++){
analogWrite(rightMotorPin, i);
delay(10);
}
delay(100);
digitalWrite(rightMotorPin, LOW);
} else if (sideToVibrate == 'L'){
for (int i = 0; i < 256; i++){
analogWrite(leftMotorPin, i);
delay(10);
}
delay(100);
digitalWrite(leftMotorPin, LOW);
} else { //Gives a haptic error if a
for (int i = 0; i < 3; i++){ //char that's not 'L' or 'R'
digitalWrite(rightMotorPin, HIGH); //is received.
digitalWrite(leftMotorPin, HIGH);
delay(500);
digitalWrite(rightMotorPin, LOW);
digitalWrite(leftMotorPin, LOW);
delay(500);
}
}
}
Processing code
link
Photos
link
Comments
Comments from TAs
Good project -- and nice collaboration to make both of your motors vibrate together. I actually found playing your game in class to be quite engaging, and I already know my right from my left! You did a good job of making the play challenging and of making it difficult to guess what was going to come next.