Wednesday, May 24, 2017
Target Game
Hook up the following circuit starting with the servo first.
int sensorPin = A0;
int ledPin = 13;
int sensorValue;
#include <Servo.h>
Servo myservo;
void setup()
{
myservo.attach(9);
pinMode(ledPin, OUTPUT);
//Serial.begin(9600);
}
void loop()
{
sensorValue = analogRead(sensorPin);
//Serial.println(sensorValue); // Print value to monitor
analogWrite(ledPin, sensorValue);
if (sensorValue < 100)
{
myservo.write(180); // tell servo to go to position in variable 'pos'
delay(15);
}
else
{
myservo.write(90);
delay(2000);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment