Advertisement
RuiViana

RC_IR_LCD

Dec 18th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.17 KB | None | 0 0
  1. #include <Servo.h>
  2. #include <LiquidCrystal.h>
  3. #include <IRremote.h>
  4.  
  5. // variaveeis dos codigos enviados pelo controle remoto
  6. #define Liga 0x815628D7 // tecla ligar menor
  7. #define LigaM 0x815648B7 // tecla ligar maior
  8. #define fundo 0x815658A7 // ??
  9. #define VOLmais 0x8156B847 // tecla que abre capacete
  10. #define VOLmenos 0x81569867 // tecla que fecha o capacete
  11.  
  12. //Pinos
  13. LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // pinos do lcd
  14. // >>> Pra pino #define ao inves de int
  15. #define led 8 // LED
  16. #define RECV_PIN 9 // Pino para recebe o sinal do RC
  17. #define Luz_Fundo 10 // Luz de fundo do LCD
  18. Servo servo; // cria um objeto servo
  19.  
  20. /*******************************************************
  21. * os pinos dos componentes sao os seguintes: /
  22. * lcd= 7 6 5 4 3 2 /
  23. * luz de fundo do lcd = 10 /
  24. * servo = 12 /
  25. * leds=8 /
  26. * recetor IR= 9 /
  27. *******************************************************/
  28.  
  29. IRrecv irrecv(RECV_PIN); //sistema infravermelho
  30. IRsend irsend; // ??
  31.  
  32. decode_results results; // ??
  33.  
  34. //---------------------------------------------------------------
  35. void setup()
  36. {
  37. servo.attach(12); // Coloca servo no pino 12
  38. Serial.begin(9600); // Inicia conexao serial
  39. irrecv.enableIRIn(); // Inicia receptor IR
  40. pinMode(led,OUTPUT); // Indica qua o led é uma saida
  41. digitalWrite(led, HIGH); // Liga o LED (HIGH = nivel lógico alto)
  42. delay(500); // Espera um segundo
  43. digitalWrite(led, LOW); // Desliga o LED (LOW = nivel lógico baixo)
  44. delay(500);
  45. digitalWrite(led, HIGH); // Liga o LED (HIGH = nivel lógico alto)
  46. delay(500); // Espera um segundo
  47. digitalWrite(led, LOW); // Desliga o LED (LOW = nivel lógico baixo)
  48. pinMode(Luz_Fundo,OUTPUT); // Define o pino como saída
  49. digitalWrite(Luz_Fundo,HIGH); // Liga luz de fundo LCD
  50. lcd.setCursor(0, 0); // Cursor pos 0 lin 0
  51. lcd.print("Mark 1.0 ");
  52. lcd.setCursor(0, 1); // Cursor pos 0 lin 1
  53. lcd.print("Loading . . . "); // Txt to LCD
  54. lcd.clear();
  55. delay(2000); // Delay 2 Seg
  56. lcd.setCursor(0, 0); // Cursor pos 0 lin 0
  57. lcd.print("J.A.R.V.I.S "); // Txt to LCD
  58. lcd.setCursor(0, 1); // Cursor pos 0 lin 1
  59. lcd.print("Ready . . . ");
  60. delay(2000); // Delay 2 Seg
  61. lcd.clear();
  62. lcd.setCursor(0,0); // Cursor pos 0 lin 0
  63. lcd.print("J.A.R.V.I.S 1.0"); // Txt to LCD
  64. lcd.setCursor(0, 1); // Cursor pos 0 lin 1
  65. lcd.print("What you need? Sr."); // Txt to LCD
  66. }
  67. //---------------------------------------------------------------
  68. void loop()
  69. {
  70. if (irrecv.decode(&results)) // Se receber coodes pelo IR
  71. {
  72. Serial.println(results.value, HEX); // Imprime o code em HEX na printer
  73. irrecv.resume(); // Recebe proximo valor
  74. }
  75.  
  76. if (results.value == Liga) // Neste bloco iremos ligar os olhos
  77. {
  78. digitalWrite(led, HIGH); // Apaga LED
  79. delay(200); // Delay 0,2 Seg
  80. digitalWrite(led,LOW); // Acende LED
  81. delay(200); // Delay 0,2 Seg
  82. digitalWrite(led, HIGH); // Apaga LED
  83. lcd.clear(); // Limpa LCD
  84. lcd.setCursor(0, 0); // Cursor pos 0 lin 0
  85. lcd.print("Eyes on "); // Txt to LCD
  86. delay(1000); // Delay 1 Seg
  87. lcd.setCursor(0, 1); // Cursor pos 0 lin 1
  88. lcd.print("Anything else Sr.?"); // Txt to LCD
  89. }
  90.  
  91. if (results.value == LigaM) // Neste bloco iremos desligar os olhos
  92. {
  93. digitalWrite(led,LOW); // Acende LED
  94. lcd.clear(); // Limpa LCD
  95. lcd.print("Eyes off "); // Txt to LCD
  96. delay(1000); // Delay 1 Seg
  97. lcd.setCursor(0, 1); // Cursor pos 0 lin 1
  98. lcd.print("Anything else Sr.?"); // Txt to LCD
  99. }
  100.  
  101. if (results.value == fundo) // Neste bloco iremos altera o fundo no lcd
  102. {
  103. lcd.clear(); // Limpa LCD
  104. lcd.setCursor(0, 0); // Cursor pos 0 lin 0
  105. lcd.print("Fundo atualizado"); // Txt to LCD
  106. lcd.setCursor(0, 1); // Cursor pos 0 lin 1
  107. lcd.print("Anything else Sr.?"); // Txt to LCD
  108. }
  109.  
  110. if (results.value == VOLmais) // Neste bloco iremos abrir os capacete
  111. {
  112. servo.write(360); // Move o Servo,
  113. delay(2000); // por 2 Seg
  114. lcd.clear(); // Limpa LCD
  115. lcd.setCursor(0, 0); // Cursor pos 0 lin 0
  116. lcd.print("Helmet Opened"); // Txt to LCD
  117. delay(1000); // Delay 1 Seg
  118. lcd.setCursor(0, 1); // Cursor pos 0 lin 1
  119. lcd.print("Anything else Sr.?"); // Txt to LCD
  120. }
  121.  
  122. if (results.value == VOLmenos) // Neste bloco iremos fechar o capacete
  123. {
  124. servo.write(0); // Move o Servo,
  125. delay(2000); // por 2 Seg
  126. lcd.clear(); // Limpa LCD
  127. lcd.setCursor(0, 0); // Cursor pos 0 lin 0
  128. lcd.print("Helmet closed"); // Txt to LCD
  129. delay(1000); // Delay 1 Seg
  130. lcd.setCursor(0, 1); // Cursor pos 0 lin 1
  131. lcd.print("Anything else Sr.?"); // Txt to LCD
  132. }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement