This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> // servo library | |
Servo servo1; // servo control object | |
// analog input initialization | |
int sensorPin = A0; | |
void setup() | |
{ | |
servo1.attach(9); | |
} | |
void loop() | |
{ | |
int sensorValue; | |
// read sensor value | |
sensorValue = analogRead(sensorPin); | |
// map the inout value to usable range | |
int tilt = map(sensorValue , 0, 1023, 13, 168 ); | |
// writes to the servo so it would tilt | |
servo1.write( tilt ); | |
} |
No comments:
Post a Comment