Description
For this week's lab, I used several sticky notes glued together and pinned on the DC motor with two magnets to evaluate the speed and force of the DC motor. I managed to have two levels of colored pinwheels spinning at the same time, but in the video I only captured my first version with one colored pinwheel:
http://www.youtube.com/watch?v=spzkZPI3YD4
Components
1 Arduino Uno
1 Breadboard
1 potentiometer
1 DC motor
1 resistor
2 small magnets
several sticky notes
cables
Code
/*
* one pot controls one motor
* modified version of AnalogInput
*/
int potPin = 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(potPin); // read the value from the sensor, between 0 - 1024
Serial.println(val);
analogWrite(motorPin, val/4); // analogWrite can be between 0-255
}
- Login to post comments