document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <LiquidCrystal.h>
  2.  
  3. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  4.  
  5. int incomingByte = 0;
  6. byte crs = 0;
  7. byte bars[8][8] =
  8. {
  9. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B },
  10. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x1B },
  11. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x1B },
  12. { 0x00, 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x1B, 0x1B },
  13. { 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B },
  14. { 0x00, 0x00, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B },
  15. { 0x00, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B },
  16. { 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B },
  17. };
  18.  
  19.  
  20.  
  21. const unsigned int upperThreshold = 70;
  22. const unsigned int lowerThreshold = 50;
  23.  
  24. unsigned long lastTime = 0;
  25. bool lastState = false;
  26.  
  27.  
  28. void setup()
  29. {
  30. //Setup LCD
  31. lcd.begin(16, 2);
  32.  
  33. // Special chars (bars)
  34. for (byte bar = 0; bar < 8; bar++)
  35. {
  36. lcd.createChar( bar, bars[bar] );
  37.  
  38. }
  39.  
  40. //Startup display message
  41. lcd.clear();
  42. lcd.print("RF 433mhz sniffer");
  43. lcd.setCursor(0, 1);
  44. lcd.print("Avvio");
  45. for (byte test = 0; test < 8; test++)
  46. {
  47. lcd.write(test);
  48. delay(100);
  49. }
  50.  
  51. // Setup wireless
  52. Serial.begin(2400);
  53. delay(500);
  54. }
  55. void loop()
  56. {
  57.  
  58. if (Serial.available() > 0)
  59. {
  60. doubleBar();
  61. }
  62.  
  63. incomingByte = 0;
  64. }
  65. void doubleBar()
  66. {
  67. static byte lastScaledValue = 0;
  68. bool signalState;
  69. unsigned int signalStabilityRange = 25;
  70. byte vLine = 0;
  71.  
  72. incomingByte = Serial.read();
  73.  
  74. if ( incomingByte > upperThreshold || incomingByte < lowerThreshold )
  75.  
  76. {
  77. signalState = true;
  78. }
  79. else
  80. {
  81. signalState = false;
  82. crs = 0;
  83. lcd.clear();
  84. }
  85.  
  86.  
  87. if (lastState != signalState)
  88. {
  89. lastTime = millis();
  90. lastState = signalState;
  91. }
  92.  
  93. if ( (millis() > lastTime + signalStabilityRange) && signalState && incomingByte < 250 )
  94. {
  95. lastTime = millis();
  96. signalState = false;
  97. lastState = false;
  98.  
  99. byte vMetter = (byte) (incomingByte / 16);
  100.  
  101.  
  102. lcd.setCursor(crs + 1, 1);
  103. lcd.print(" ");
  104.  
  105. if (vMetter < 9)
  106. {
  107. vLine = vMetter;
  108. lcd.setCursor(crs, 0);
  109. lcd.print(" ");
  110.  
  111. lcd.setCursor(crs, 1);
  112. if (vLine > 0)
  113. {
  114. lcd.write(vLine - 1);
  115. }
  116. else
  117. {
  118. lcd.print(" ");
  119. }
  120.  
  121. }
  122. else
  123. {
  124. vLine = vMetter - 9;
  125.  
  126. lcd.setCursor(crs, 0);
  127. lcd.write(vLine);
  128.  
  129. lcd.setCursor(crs, 1);
  130. lcd.write(7);
  131.  
  132. }
  133.  
  134. crs++;
  135.  
  136. if (crs > 15)
  137. {
  138. crs = 0;
  139. }
  140. }
  141. }
');