Skip to content

Instantly share code, notes, and snippets.

@sfambach
Created July 19, 2019 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfambach/bb2b210a249db7909514005069925c77 to your computer and use it in GitHub Desktop.
Save sfambach/bb2b210a249db7909514005069925c77 to your computer and use it in GitHub Desktop.
Petentiometer controles Servo (Simple mapping example)
/** 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