Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
160
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. #include <math.h>
  3.  
  4. int motor_pin[4] = {
  5. 3, 5, 6, 9};
  6.  
  7. Servo motor[4];
  8. int throttle[4] = {
  9. 20, 20 ,20 ,20};
  10.  
  11. void sendSignalToMotor() {
  12. int c;
  13. for(c=0; c<4; c++) {
  14. int fix = (int)tFix[c];
  15. motor[c].write(throttle[c] + fix);
  16. }
  17. }
  18.  
  19. void setup()
  20. {
  21. int c;
  22. Serial.begin(9600);
  23. delay(10);
  24. Serial.println("initialize!");
  25.  
  26. for(c=0; c<4; c++){
  27. throttle[c] = 15;
  28. motor[c].attach(motor_pin[c]);
  29. }
  30.  
  31. // 5 sec low throttle for setup
  32. int d;
  33. for(d=0; d<500; d++){
  34. sendSignalToMotor();
  35. delay(10);
  36. }
  37.  
  38. for(c=0; c<4; c++){
  39. throttle[c] = 50;
  40. }
  41. }
  42.  
  43.  
  44. void loop()
  45. {
  46. sendSignalToMotor();
  47. delay(10);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement