You are on page 1of 1

#include <AFMotor.

h>
AF_DCMotor motor(4); // create motor #2, 64KHz pwm
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
motor.setSpeed(200); // set the speed to 200/255
int sensorVal;
}
void loop() {
// Reading the sensor Value
sensorVal = analogRead(A0);
if(sensorVal >=600){
// If the value of sensor is greater than 600
motor.run(FORWARD);
Serial.println('Motor is ON');
}
else{
// If the value of sensor is less than 600
motor.run(RELEASE);
Serial.println('Motor is OFF');
}

You might also like