Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Vorhergehende ÜberarbeitungLetzte Überarbeitung | |||
— | project:arduino-kickstarter-servo [14.01.2013 15:56] – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | {{: | ||
+ | |||
+ | < | ||
+ | |||
+ | // Controlling a servo position using a potentiometer (variable resistor) | ||
+ | // by Michal Rinott < | ||
+ | |||
+ | #include < | ||
+ | |||
+ | Servo myservo; | ||
+ | |||
+ | int potpin = 0; // analog pin used to connect the potentiometer | ||
+ | int val; // variable to read the value from the analog pin | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | myservo.attach(3); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | val = analogRead(potpin); | ||
+ | val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) | ||
+ | myservo.write(val); | ||
+ | delay(15); | ||
+ | } | ||
+ | |||
+ | </ |