User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Lab 6: DC Motor - Car

Submitted by ashley on Wed, 10/15/2008 - 21:44

Assignment: DC Motor: Actuation Assignment 1

Collaborators:

Assignment: DC Motor: Actuation Assignment 1
Collaborators:

 

I did not alter the code from the example, but rigged up a little car to the DC Motor. Controlled by the potentiometer. Did not have much success with the car, as the motor did not have enough power to drive the axle under tension by the elastic band that was the drive train.
/*
 * one pot 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 = 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-125); // analogWrite can be between 0-255    
  
}