Advertisement
D0cEvil

C - RoboLizard Source code

Jan 4th, 2023
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.45 KB | Source Code | 0 0
  1. # Робот Ростика
  2.  
  3. #include <boarddefs.h>
  4. #include <IRremoteInt.h>
  5. #include <ir_Lego_PF_BitStreamEncoder.h>
  6.  
  7. #include <Servo.h>
  8. #include <IRremote.h>
  9.  
  10. Servo Servo_1;
  11. Servo Servo_2;
  12. Servo Servo_3;
  13.  
  14. int RECV_PIN = 7; # Пизданутые китайцы в инструкции указывают 5-й пин!!!!
  15. int array_setup[] = {60,160,80};//Set the original angle of the servo
  16. int angle1 = 25,angle2 = 35,angle3 = 55;
  17. int delayedTime1 = 10;//The time needed for rotating 1 degree of the servo
  18.  
  19.  
  20. long KEY_CODE_forward = 0xFF02FD;
  21. long KEY_CODE_back = 0xFFC23D;
  22. long KEY_CODE_ADD = 0xFF906F;
  23. long KEY_CODE_SUB = 0xFFA857;
  24. long KEY_CODE_playback = 0xFF9867;
  25. long KEY_CODE_usd = 0xFFB04F;
  26. long KEY_CODE_2 = 0xFF18E7;
  27. long KEY_CODE_3 = 0xFF7A85;
  28. long KEY_CODE_4 = 0xFF10EF;
  29. long KEY_CODE_5 = 0xFF38C7;
  30. long KEY_CODE_6 = 0xFF5AA5;
  31. long KEY_CODE_7 = 0xFF42BD;
  32. long KEY_CODE_8 = 0xFF4AB5;
  33. long KEY_CODE_9 = 0xFF52AD;
  34. long KEY_CODE_MODE = 0xFF629D;
  35. long KEY_CODE_MUTE = 0xFFE21D;
  36. long KEY_CODE_LONG_PRESS = 0xFFFFFFFF;
  37. long longPressKey = -1;
  38.  
  39. IRrecv irrecv(RECV_PIN);
  40. decode_results results;
  41.  
  42.  
  43. /*
  44.  - setup function
  45.  * ---------------------------------------------------------------------------*/
  46. void setup()
  47. {
  48.   //Start the serial for debug.
  49.   Serial.begin(115200);
  50.   irrecv.enableIRIn();
  51.  
  52.   //Attach the servos on pins to the servo object
  53.   Servo_1.attach(2);
  54.   Servo_2.attach(3);
  55.   Servo_3.attach(4);
  56.   Servo_1.write(array_setup[0]);
  57.   Servo_2.write(array_setup[1]);
  58.   Servo_3.write(array_setup[2]);
  59.   delay(1000);
  60. }
  61.  
  62. /*
  63.  - loop function
  64.  * ---------------------------------------------------------------------------*/
  65. void loop()
  66. {
  67.   //Print the data.
  68.   if (irrecv.decode(&results))
  69.   {
  70.     Serial.println(results.value,HEX);//Infrared encode of serial printing
  71.     irrecv.resume();
  72.   }
  73.  
  74.   //number 2 button
  75.   if (results.value == KEY_CODE_2)
  76.   {
  77.     keyTwo();
  78.   }
  79.  
  80.    //ADD button
  81.   if (results.value == KEY_CODE_ADD)
  82.   {
  83.     delayedTime1 = 8;
  84.     keyADD();
  85.   }
  86.  
  87.    //number 5 button
  88.   if (results.value ==KEY_CODE_5)
  89.   {
  90.     delayedTime1 = 16;
  91.     keyFive();
  92.   }
  93.  
  94.    //number 4 button
  95.   if (results.value == KEY_CODE_4)
  96.   {
  97.     keyFour();
  98.   }
  99.  
  100.    //number 6 button
  101.   if (results.value == KEY_CODE_6)
  102.   {
  103.     keySix();
  104.   }
  105.  
  106.    //number 8 button
  107.   if (results.value == KEY_CODE_8)
  108.   {
  109.     keyEight();
  110.   }
  111.  
  112.    //SUB button
  113.    if (results.value == KEY_CODE_SUB)
  114.   {
  115.      keySUB();
  116.   }
  117.   }
Tags: Robots
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement