To make the piece I described earlier, wire it as indicated with an Arduino Uno and put this as the programming:
//This will run a motor for 1/100th of a second once every two hours. I’m using it as a calendar of sorts, so that my time at New College is represented by a small car going down a long hallway. Mine moves about 1’ every month.
int motorPin = 9;
int val = 0; // variable to store the data from the serial port
void setup() {
pinMode(motorPin,OUTPUT); // declare the motor’s pin as output
Serial.begin(19200); // connect to the serial port
Serial.println(“Welcome to SerialMotorSpeed!”);
Serial.println(“Enter speed number 0-9:”);
}
void loop () {
val = Serial.read(); // read the serial port
if (val >= ‘0’ && val <= ‘9’ ) {
val = val - ‘0’; // convert from character to number
val = 28 * val; // convert from 0-9 to 0-255 (almost)
Serial.print(“Setting speed to “);
Serial.println(val);
analogWrite(motorPin,val);
Serial.println(“Enter speed number 0-9:”);
}
digitalWrite (motorPin, HIGH); // turn motor on
delay(10); // for 1/100th second
digitalWrite(motorPin, LOW); // turn motor off
delay(7199990); // for almost two hours
-
quellecoincidence liked this
-
andrewfishman posted this