Skip to content

Instantly share code, notes, and snippets.

@Ignaciowillats
Last active January 23, 2017 14:09
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 Ignaciowillats/c8e72989bbfe5b464b9a92eb082203ec to your computer and use it in GitHub Desktop.
Save Ignaciowillats/c8e72989bbfe5b464b9a92eb082203ec to your computer and use it in GitHub Desktop.
DIY Centrifuge
#include
Servo myservo;
int potpin = A0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int listo = 13;
void setup() {
pinMode(listo, OUTPUT); digitalWrite(listo, LOW);
myservo.attach(9); //Control pin to ESC
arm(); //Function to arm the esc
}
void loop() {
digitalWrite(listo, HIGH); //Prepared saw LED flashing
delay(200);
digitalWrite(listo, LOW);
delay(200);
// reads the value of the potent. (value between 0 and 1023)
val = analogRead(potpin);
// scale it to use it with motor. Limited to 100.
val = map(val, 0, 1023, 55, 140);
myservo.write(val);
}
void arm() { //Arming function
myservo.write(0);
delay(1000);
myservo.write(30);
delay(3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment