Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <RH_ASK.h>
  2. #include <SPI.h> // Not actually used but needed to compile
  3. #include <PCD8544.h> //LCD include
  4.  
  5. RH_ASK driver;
  6.  
  7. static PCD8544 lcd;
  8.  
  9. int potPin = A0; //select the input pin for the potentiometer
  10. int val = 0; //variable to store the value coming from the sensor
  11.  
  12. String tussenwaarde = "";
  13. String waarde = "";
  14. String eindwaarde = "";
  15.  
  16. void setup()
  17. {
  18.  
  19.  
  20. Serial.begin(9800); // Debugging only
  21. if (!driver.init())
  22. Serial.println("init failed");
  23.  
  24.  
  25. // PCD8544-compatible displays may have different resolution
  26. lcd.begin(84, 48);
  27. }
  28.  
  29. void loop()
  30. {
  31.  
  32. val = analogRead(potPin); //reading the potentiometer
  33. waarde = String(val);
  34. delay(200);
  35. Serial.println(waarde);
  36.  
  37. // Write the first line of the message
  38. lcd.setCursor(0, 0);
  39. lcd.print("Message send = ");
  40.  
  41. // Write the counter on the second line...
  42. lcd.setCursor(0, 1);
  43. lcd.print(waarde);
  44. lcd.write(' ');
  45.  
  46. int str_length = waarde.length() + 1;
  47. char tosend[waarde.length() + 1];
  48. waarde.toCharArray(tosend, sizeof(waarde));
  49.  
  50. const String *analog = val;
  51.  
  52. //const char *msg = "Hello World!";
  53. driver.send((uint8_t *)tosend, str_length);
  54. driver.waitPacketSent();
  55. //delay(1000);
  56. //Serial.println(analog);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement