Skip to content

Instantly share code, notes, and snippets.

Created July 12, 2018 08:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save elktros/52fb6f3f8614173b4ddf3275bb26adbf to your computer and use it in GitHub Desktop.
Code for controlling a Servo motor with Flex Sensor and Arduino.
#include <Servo.h>
Servo myServo;
const int flexPin = A0;
void setup()
void loop()
int flexValue;
int servoPosition;
flexValue = analogRead(flexPin);
servoPosition = map(flexValue, 800, 900, 0, 180);
servoPosition = constrain(servoPosition, 0, 180);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment