DC motors and Potentiometer (Arduino)
1 min readOct 20, 2022
Albert Hodo. Tangibe User Interface, Fall 2022
Prompt:Explore motion as an output, in a form of a display or tactile feedback. Use your DC motor to create a vibration or rotational motion (e.g., pinwheels, dancing wires, etc.)
Components Used
- Bread Board
- Arduino Uno
- Jump Wires
- 1 10K Resister
- 1 Transistor
- 1 Capacitor
- Batteries and Battery Pack
Process
I attached a folded paper with 2 pointed edges to the DC motor to act create a fan and used the potentiometer to control the speed on the fan.
Code
/* DC Motor with potentiometer control
* Theory and Practice of Tangible User Interfaces
* Fall 2022
*/
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);
}
Demo
Demo with Off-center Material