Fritzing Diagram.
CHANGING WHEEL SPEED WITH LIGHT INTENSITY
CODE AND DIAGRAMĀ 
//with light input
int analogInPin = A0;
int sensorValue = 0;
int outputValue = 0;
int transistorPin = 3;
int sensorValueLight;
int sensorLow = 1023;
int sensorHigh = 0;
const int ledPin = 13;
void setup()
{
Serial.begin(9600);
pinMode(transistorPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
sensorValueLight = analogRead(A0);
if (sensorValueLight > sensorHigh){
sensorHigh = sensorValueLight;
}
if (sensorValueLight > sensorLow){
sensorLow = sensorValueLight;
}
digitalWrite(ledPin, LOW);
}
void loop()
{
sensorValue = analogRead(A0);
outputValue = map(sensorValue, 0, 1023, 0, 255);
analogWrite(transistorPin, sensorValue);
Serial.println(sensorValue);
delay(10); }

Link to Project Progress: http://itgmteam1-347.tumblr.com/
Back to Top