Last active
January 23, 2017 14:09
-
-
Save Ignaciowillats/c8e72989bbfe5b464b9a92eb082203ec to your computer and use it in GitHub Desktop.
DIY Centrifuge
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
#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