ASSIGNMENT
Connect a DC motor and a force sensor and create and Arduino program and/or object that displays the use of a motor.
MATERIALS USED
1 DC Motor, 1 FSR, 1 Bunny, 1 Toilet Paper Roll, 1 Butterfly Clip,
1 Plastic Hairspray Bottle Cap, Magnet, Electrical Tape
ARDUINO CODE
NOTE: Basically the same as the example file--I worked on putting the motor into and object.
/*
* FSR 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 potPin_fsr = 0; // select the input pin for the FSR
int motorPin = 9; // select the pin for the Motor
int speakerPin = 6;
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(potPin_fsr); // read the value from the sensor, between 0 - 1024
Serial.println(val);
analogWrite(motorPin, val/4); // analogWrite can be between 0-255
digitalWrite(speakerPin, LOW);
}