Download libraries/Stepper/examples/MotorKnob/MotorKnob.ino from Beifengdo/Arduino-Development: direct link, hf CLI and curl.
- Browser
- Download file 863 Bytes
-
https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/libraries/Stepper/examples/MotorKnob/MotorKnob.ino
- Command line
-
hf download hf://datasets/Beifengdo/Arduino-Development/libraries/Stepper/examples/MotorKnob/MotorKnob.ino
-
curl -L -o MotorKnob.ino https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/libraries/Stepper/examples/MotorKnob/MotorKnob.ino
863 Bytes
| /* | |
| * MotorKnob | |
| * | |
| * A stepper motor follows the turns of a potentiometer | |
| * (or other sensor) on analog input 0. | |
| * | |
| * http://www.arduino.cc/en/Reference/Stepper | |
| * This example code is in the public domain. | |
| */ | |
| // change this to the number of steps on your motor | |
| // create an instance of the stepper class, specifying | |
| // the number of steps of the motor and the pins it's | |
| // attached to | |
| Stepper stepper(STEPS, 8, 9, 10, 11); | |
| // the previous reading from the analog input | |
| int previous = 0; | |
| void setup() { | |
| // set the speed of the motor to 30 RPMs | |
| stepper.setSpeed(30); | |
| } | |
| void loop() { | |
| // get the sensor value | |
| int val = analogRead(0); | |
| // move a number of steps equal to the change in the | |
| // sensor reading | |
| stepper.step(val - previous); | |
| // remember the previous value of the sensor | |
| previous = val; | |
| } |