mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-28 05:01:28 +03:00
First integration of the Arduino code in Processing 5503: PreProcessor and Compiler have been integrated with changes to the Sketch.
Compilation still has problems (Thread error on success, and can't handle non-pde files in a sketch). Modified the Mac OS X make.sh to copy the hardware, avr tools, and example over. Removing some of the antlr stuff. Disabling the Commander (command-line execution) for now. Added Library, LibraryManager, and Target. Added support for prefixed preferences (e.g. for boards and programmers).
This commit is contained in:
40
hardware/libraries/Stepper/examples/MotorKnob/MotorKnob.pde
Normal file
40
hardware/libraries/Stepper/examples/MotorKnob/MotorKnob.pde
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* MotorKnob
|
||||
*
|
||||
* A stepper motor follows the turns of a potentiometer
|
||||
* (or other sensor) on analog input 0.
|
||||
*
|
||||
* http://www.arduino.cc/en/Reference/Stepper
|
||||
*/
|
||||
|
||||
#include <Stepper.h>
|
||||
|
||||
// change this to the number of steps on your motor
|
||||
#define STEPS 100
|
||||
|
||||
// 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;
|
||||
}
|
Reference in New Issue
Block a user