Assignment: DC Motor: Actuation Assignment 1
Collaborators:
Description
iPurr simulates a cat purring. When you stroke iPurr it purrs, just like a real cat! iPurr uses an FSR and weighted DC motor to simulate the purr response of a contented cat.
Photos
Components
- Force Sensing Resistor
- DC Motor
- Arduino
- Paint Cap
- Play Dough
- Tribble Plush Toy
Code
/*
* iPurr
* Takes input from FSR and Out puts to a DC motor
* Jessica Voytek October, 2009
*
* Adapted from:
* one pot fades one motor
* modified version of AnalogInput
* by DojoDave <http://www.0j0.org>
* http://www.arduino.cc/en/Tutorial/AnalogInput
* Modified again by dave
*
*/
int fsrPin = 0; // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(fsrPin); // read the value from the sensor, between 0 - 1024
Serial.println(val);
if (val < 100) {
notify();
}
}
void notify() {
analogWrite(motorPin, 50);
delay(1000);
analogWrite(motorPin, 100);
delay(1000);
analogWrite(motorPin, 50);
delay(1000);
analogWrite(motorPin, 100);
delay(1000);
analogWrite(motorPin, 50);
delay(1000);
analogWrite(motorPin, 100);
delay(1000);
analogWrite(motorPin, 50);
delay(1000);
analogWrite(motorPin, 100);
delay(1000);
analogWrite(motorPin, 0);
}