Created
July 19, 2019 12:36
-
-
Save sfambach/bb2b210a249db7909514005069925c77 to your computer and use it in GitHub Desktop.
Petentiometer controles Servo (Simple mapping example)
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
/** Servo test with potentiometer | |
* http://wwww.fambach.net | |
* GPLv2 | |
*/ | |
#include <Servo.h> | |
#define SERVO A3 | |
#define POTI A0 | |
Servo s1; | |
void setup() { | |
Serial.begin(115200); | |
pinMode(POTI, INPUT); | |
s1.attach(SERVO); | |
} | |
void loop() { | |
int poti = analogRead(POTI); | |
int servo = map(poti, 0, 1023, 0, 180); | |
s1.write(servo); | |
Serial.print("Poti:\t"); | |
Serial.print(poti); | |
Serial.print("\tServo:\t"); | |
Serial.print(servo); | |
Serial.print('\n'); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment