DC Motor Exercise

Circuit:

Functioning:

With potentiometer:

Update: I found the one above was still connected to my computer, so this is how it works only with power supplier. I also mapped the output value into a smaller range.

Code: 
int analogInPin = A0;
int sensorValue = 0;
int outputValue = 0;
void setup() {
  Serial.begin(9600);
  pinMode(9, OUTPUT);
}
void loop() {
  sensorValue = analogRead(analogInPin);
  outputValue = map(sensorValue, 0, 1023, 25, 88);
  Serial.println(outputValue);
  analogWrite(9, 50);
  delay(100);
}

Leave a Reply

Your email address will not be published. Required fields are marked *