Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*ElectroCrea.com
  2.  
  3. Receptor     Arduino
  4. ----------------------------
  5.  VCC         5V
  6.  GND         GND
  7.  OUT         12              
  8. */
  9. #include <VirtualWire.h>//Incluimos esta librería
  10. int led = 13;
  11. ////////////////////////////////////////////////////////////////////VOID SETUP
  12. void setup(){
  13. vw_set_ptt_inverted(true);
  14. vw_set_rx_pin(12);//Pin de Arduino
  15. vw_setup(4000);//Velocidad de la transmisión de datos
  16. pinMode(led, OUTPUT);
  17. vw_rx_start();    
  18. }
  19. ////////////////////////////////////////////////////////////////////VOID LOOP
  20. void loop(){
  21. uint8_t buf[VW_MAX_MESSAGE_LEN];
  22. uint8_t buflen = VW_MAX_MESSAGE_LEN;
  23. if (vw_get_message(buf, &buflen)){ //No bloqueada
  24.  
  25. ////////////////////////////ACCION 1  
  26. if(buf[0]=='1'){//Si recibimos 1
  27. digitalWrite(led,HIGH);//Se enciende el led
  28. }
  29. ////////////////////////////ACCION 2
  30. if(buf[0]=='2'){
  31. digitalWrite(led,LOW);//Se apaga el led
  32. }
  33. ////////////////////////////ACCION 3
  34. if(buf[0]=='3'){
  35. digitalWrite(led,LOW);//Parpadea el led
  36. delay (200);
  37. digitalWrite(led,HIGH);
  38. delay (200);
  39. }
  40.  
  41. }
  42. }
  43. //Mas información en ElectroCrea.com