Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- #include <Servo.h>
- Servo thumb;
- Servo index;
- Servo middle;
- Servo ring;
- Servo pinky;
- SoftwareSerial bluetooth(3, 2); // RX, TX
- void setup() {
- Serial.begin(9600);
- bluetooth.begin(9600);
- thumb.attach(4);
- index.attach(5);
- middle.attach(6);
- ring.attach(7);
- pinky.attach(8);
- }
- void loop() {
- if (bluetooth.available() > 0) {
- char received = bluetooth.read();
- if (received == '0') {
- thumb.write(0);
- pinky.write(0);
- ring.write(0);
- middle.write(0);
- index.write(0);
- } else if (received == '1') {
- index.write(90);
- pinky.write(0);
- ring.write(0);
- middle.write(0);
- thumb.write(0);
- } else if (received == '2') {
- index.write(90);
- middle.write(90);
- pinky.write(0);
- ring.write(0);
- thumb.write(0);
- } else if (received == '3') {
- index.write(90);
- middle.write(90);
- ring.write(90);
- pinky.write(0);
- thumb.write(0);
- } else if (received == '4') {
- index.write(90);
- middle.write(90);
- ring.write(90);
- pinky.write(90);
- thumb.write(0);
- } else if (received == '5') {
- index.write(90);
- middle.write(90);
- ring.write(90);
- pinky.write(90);
- thumb.write(90);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement