Description:
For this lab, I wanted to test how much power our little DC motors have. Since it’s acknowledged that they don’t have much torque, I didn’t want to choose something too heavy, but I did want to extend the range of the spinning motion so that it would be visible from far away. Looking around my apartment, I happened to have a poster tube sitting around, which I realized would make the perfect object: it’s long but slender, doesn’t weigh much but it stable, and is round, so I could fairly easily spin it with the motor without getting too much vibration.
So, I created a monochrome version of a barber’s pole:
First, I used the potentiometer as the speed control so that I could “lock in” a spin speed:
But after that, I wanted to try out using the FSR so that I could control the spin while holding the motor, so that I’d have I/O coincidence. That’s what I’ll be demonstrating in class.
One interesting observation I had was that with a heavy-ish weight, the motor takes quite a bit of “revving” to get to a level of power sufficient to overcome the inertia. And then, after removing power, my barber pole keeps spinning for quite some time. Interesting to watch it in action.
Components:
- Arduino Uno
- breadboard
- 1 DC motor
- 1 Transistor
- 1 Diode
- 2 resistors (one 1KΩ, one 10KΩ)
- 1 FSR (or potentiometer)
- 1 poster tube, decorated
- piece of cork (to provide friction and hold the motor in place on the end of the tube)
- battery pack
- two AA batteries
- jumper wires
Code:
(This is the final code, using the FSR rather than the potentiometer.)
int potPin = 0; // select the input pin for the potentiometer/FSR
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 - 1023
val = map(val, 0, 1023, 0, 255);
Serial.println(val);
analogWrite(motorPin, val); // analogWrite can be between 0-255
}