i play with led and photocell,
placing them in a dark coll box,
using photocell val to control motor speed.
code:
/*
* one pot fades one motor
* modified version of AnalogInput
* by DojoDave <http://www.0j0.org>
* Modified again by dave
*/
int ledPin = 7;
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);
pinMode(ledPin, OUTPUT);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024
Serial.println(val);
analogWrite(motorPin, val/4);
delay(1000);
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(5000); // analogWrite can be between 0-255
}
Comments
Comments from TAs
This seems to work, but it's not clear what type of interaction you're trying to create with the photocell/motor speed interaction -- What is the relationship between the two components, and what type of interface might be built around the interaction?
Your photo makes it fairly difficult to see what your interface actually does. Do you have a clearer one?