добавлена библиотека servo, прерывание для нее и дефайны по времени
This commit is contained in:
1 parent
63217147e5
commit
2dc71c2171
11 files changed
+943
No files matched your search
@@ -0,0 +1,26 @@
|
||||
|
||||
/*
|
||||
"Resist"
|
||||
|
||||
This example demonstrates the servo drive movement
|
||||
depending on the value on the potentiometer
|
||||
(the example was tested on a servo drive with circular movement)
|
||||
*/
|
||||
|
||||
#include <Servo.h>
|
||||
|
||||
Servo servo; // create an Servo class instance to control the servo
|
||||
|
||||
int potpin = A0; // analog pin used to connect a potentiometer
|
||||
int val; // variable for reading the analog output value
|
||||
|
||||
void setup() {
|
||||
servo.attach(8); // connecting the servo drive to digital pin 8 (D8)
|
||||
}
|
||||
|
||||
void loop() {
|
||||
val = analogRead(potpin); // reading the potentiometer value (value from 0 to 4096)
|
||||
val = map(val, 0, 4096, 0, 180); // change scale for use with servo (value from 0 to 180)
|
||||
servo.write(val); // setting the servo position according to the value
|
||||
delay(15); // waiting for the servo to get there
|
||||
}
|
||||
Reference in new issue
Block a user