Task 1, ClauTIC League, by MadTeam


/ Published in: Processing
Save to your folder(s)

This i s the task 1 of the ClauTIC robotics league by MAD Team.


Copy this code and paste it in your HTML
  1. #include <Servo.h>
  2. Servo miservo;
  3. int Motor_Esq=7, Velocitat_Esq=6, Motor_Dret=12, Velocitat_Dret=10; //Declarem motors
  4. int t=0;
  5. int i = 0;
  6.  
  7. void setup()
  8. {
  9. pinMode(Motor_Esq, OUTPUT);
  10. pinMode(Velocitat_Esq, OUTPUT);
  11. pinMode(Motor_Dret, OUTPUT);
  12. pinMode(Velocitat_Dret, OUTPUT);
  13. miservo.attach(3);
  14. }
  15.  
  16. void loop()
  17. {
  18. if(t == 0)
  19. {
  20. //des de la base fins la primera piramide
  21. Motor_Rodes(HIGH, -250,HIGH,-250);
  22. delay(2300);
  23.  
  24. // gir a la dreta per colocar-se be a la primera piramide
  25. Motor_Rodes(HIGH, -164,LOW,-10);
  26. delay(1100);
  27.  
  28. // avançar per descarregar primera piramide
  29. Motor_Rodes(HIGH, -250,HIGH,-250);
  30. delay(285);
  31. Motor_Rodes(LOW, 0,LOW,0);
  32. delay(50);
  33.  
  34. // descarregar primera piramide
  35. descarrega();
  36.  
  37. // avançar fins segona piramide
  38. Motor_Rodes(HIGH, -250,HIGH,-250);
  39. delay(990);
  40. Motor_Rodes(LOW, 0,LOW,0);
  41. delay(10);
  42.  
  43.  
  44. // descarregar segona piramide
  45. descarrega();
  46.  
  47.  
  48. // girar per posicio tercera piramide
  49. Motor_Rodes(HIGH, -250,LOW,0);
  50. delay(900);
  51. Motor_Rodes(LOW, 0,LOW,0);
  52. delay(10);
  53.  
  54. // descarregar tercera piramide
  55. descarrega();
  56.  
  57. // tornar a la base
  58. Motor_Rodes(HIGH, -250,HIGH,-100);
  59. delay(3200);
  60. Motor_Rodes(LOW, 0,LOW,0);
  61.  
  62. t++;
  63. }
  64. }
  65.  
  66. void Motor_Rodes (char Motor_Esq_Estat, int Motor_Esq_Potencia, char Motor_Dret_Estat, int Motor_Dret_Potencia)
  67. {
  68. digitalWrite(Motor_Esq, Motor_Esq_Estat);
  69. analogWrite(Velocitat_Esq, Motor_Esq_Potencia);
  70. digitalWrite(Motor_Dret, Motor_Dret_Estat);
  71. analogWrite(Velocitat_Dret, Motor_Dret_Potencia);
  72. }
  73.  
  74. void descarrega()
  75. {
  76. miservo.write(180);
  77. delay(73);
  78. miservo.write(90);
  79. delay(1000);
  80.  
  81.  
  82.  
  83. }

URL: www.mad-team.a78.org

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.