- An arduino board
- A vibrating motor (can be found in allelectronics, in your phone, maybe the lab :) )
- wires (d'uh)
A possible code with a photosensor:
int motorPin = 9; // this is the analog output pin for the motor
int sensorPin = 3; // this is the digital input pin for the photo sensor
int photoSensor = 0; // this is a variable to hold the state of the photo sensor
void setup() {
pinMode(motorPin, OUTPUT); // set the motor pin as a analog output
pinMode(sensorPin, INPUT); // set the photo sensor pin as a digital input
}
void loop() {
photoSensor = digitalRead(sensorPin); // read the photo sensor
if (photoSensor == HIGH) { // if the photo sensor is sending 5 volts
digitalWrite(motorPin, HIGH); // turn on the motor
}
else {
digitalWrite(motorPin, LOW); // turn off the motor
}
}
hooking up the vibrating motor:
http://a.parsons.edu/~tina/wireless/archives/000087.html
how to make a vibrating motor:
http://www.instructables.com/id/ELD4XXZPWDEUK7R4W5/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment