Lab 7: Output — DC Motors
Oscar Chan
Professor Kimiko Ryokai
Info C262, Tangible User Interfaces, Fall 2021
Description
DC Motors is a way to control the rotational motion based on the direct current into the motor. Similar to how we control the brightness of LED lights back in Lab 2, we can control the speed of the motor using Pulse Width Modulation (PWM). The pins that support PWM are the ports on the Arduino Uno with a squiggly line next to the number.


The more complex component of this circuit is the Transistor, which is the circuit component with three male pins with the circle above the plastic body. The ordering of the pins, contrary to the schematic symbol, is what people who make this circuit should be careful about.

Diodes only allow current to flow in one direction, to avoid sending backward by accident any charge that may be generated by the DC Motor when spun in a certain direction by some other means other than current.

Rotational motion reminds me of windmills and spinning wheels. However, I saw my fellow classmates made windmill-like structures already during lab, so I decided to try spinning wheels for a change.
The best idea I could come up with was something similar to “Wheel of Fortune,” which lead to the idea of the spinning prize wheels. I found an online printout template for a dare wheel, which is a wheel with dares on each wedge of the board. I tried to create a spinner with the board itself staying still and only the needle moving to add a bit more complexity and thinking. Don’t worry, all of them are safe for work! They may only just be embarrassing.
To support the wheel to make sure it doesn’t spin, it is placed at the very base of the rotating axle and tapped down to be held in place. The toothpick also stabilizes the wheel so it doesn’t move as well. A paper clip tapped on a corkscrew helps give it the ability to spin.
Components Used
- Arduino Uno
- Breadboard
- Lots of Circuit Wires that can be cut
- Wire cutters
- 1 Red-colored circuit wire (for 5-volt connection)
- 1 Black-colored circuit wire (for ground)
- 1K ohm Resistor
- Diode (marked 1N4004)
- Transistor (marked TIP120)
- Battery pack and batteries that fit the pack (this lab uses 2 AA batteries with a pack for them)
- DC Motor
- Corkscrew
- Some form of input from a previous lab (this lab uses a Potentiometer)
- Dare Wheel
- Duct tape
- Paper Clip
- Tooth Pick
Code
This code is a bit similar to Lab 2, where there is a value sent to output pin 9, which supports PWM. This allows us to make the DC Motor run at various speeds.
/* DC Motor with potentiometer control
* Theory and Practice of Tangible User Interfaces
* Fall 2021
*/
int motorPin = 9;
int potPin = A0;
int potVal = 0;
int motorCtrlVal = 0;
void setup() {
pinMode(potPin, INPUT);
pinMode(motorPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
potVal = analogRead(potPin);
Serial.print("potVal: ");Serial.println(potVal);
motorCtrlVal = map(potVal, 0, 1024, 0, 255);
Serial.print("motorCtrlVal: ");Serial.println(motorCtrlVal);
analogWrite(motorPin, motorCtrlVal);
}
Images


Videos

