Advertisement
Guest User

Receiving code

a guest
Nov 7th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3.  
  4. #define MAX_FINGER 5
  5. // #include
  6. // create servo object to control a servo
  7. typedef struct {
  8. Servo myservo;
  9. byte servoAng;
  10. } SERVO;
  11.  
  12. SERVO servo[MAX_FINGER];
  13.  
  14. void setup() {
  15. Serial.begin(9600);
  16. int i = 0;
  17. for (i = 0; i < MAX_FINGER; i++) {
  18. servo[i].myservo.attach(i + 2);
  19. }
  20. }
  21.  
  22. void loop() {
  23. if(Serial.available() >=5) {
  24. int i = 0;
  25. for (i = 0; i < MAX_FINGER; i++) {
  26. servo[i].servoAng = Serial.read();
  27. servo[i].myservo.write( servo[i].servoAng );
  28. }
  29. // Send the servo to the position read... (note: you get to make this happen)
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement