Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- static const int servo1pin = D3; // = 0, "D8" - close arm segment
- static const int servo2pin = D5; // = 14, "D14/SDA/D4" - far arm segment
- static const int servo3pin = D2; // = 4, "D13/SCK/D5" - rotation
- static const int delayMs = 2500;
- String inputValue;
- int intValue = 1500;
- int target = 0;
- Servo servo1;
- Servo servo2;
- Servo servo3;
- void setup() {
- Serial.begin(115200);
- pinMode(servo1pin,OUTPUT);
- pinMode(servo2pin,OUTPUT);
- pinMode(servo3pin,OUTPUT);
- servo1.attach(servo1pin);
- servo2.attach(servo2pin);
- servo3.attach(servo3pin);
- servo1.writeMicroseconds(1500);
- servo2.writeMicroseconds(1500);
- servo3.writeMicroseconds(1500);
- }
- void setPosition(unsigned int servo, unsigned int value) {
- }
- void loop() {
- if(Serial.available()){
- inputValue = Serial.readStringUntil(' ');
- target = inputValue.toInt();
- inputValue = Serial.readStringUntil('\n');
- intValue = inputValue.toInt();
- if (target == 1) {
- servo1.writeMicroseconds(intValue);
- }
- if (target == 2) {
- servo2.writeMicroseconds(intValue);
- }
- if (target == 3) {
- servo3.writeMicroseconds(intValue);
- }
- }
- // servo1.writeMicroseconds(integerValue);
- // servo2.writeMicroseconds(integerValue);
- // servo3.writeMicroseconds(integerValue);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement