Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A test rig for Project Tagbot's brushless flywheel system.
- //#include <Serial.h>
- # include <Servo.h>
- const int escPin = A0;
- const int potPin = A1;
- const int minSpeed = 1000;
- const int maxSpeed = 2000;
- const int inThreshold = 10;
- int currentSpeed;
- Servo esc;
- void setup() {
- pinMode(potPin, INPUT);
- esc.attach(escPin);
- //esc.writeMicroseconds(1000);
- Serial.begin(9600);
- Serial.println("start");
- }
- /**/
- void loop() {
- currentSpeed = getOutputSpeed(analogRead(potPin));
- Serial.println(currentSpeed);
- esc.writeMicroseconds(currentSpeed);
- /*if (Serial.available()) {
- currentSpeed = Serial.parseInt();
- }*/
- }
- int getOutputSpeed(int inVal) {
- /*if (inVal < inThreshold) {
- return 0;
- }
- else {
- return map(inVal, inThreshold, 1023, minSpeed, maxSpeed);
- }*/
- return map(inVal, 0, 1023, minSpeed, maxSpeed);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement