safwan092

Untitled

Dec 2nd, 2018
187
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define REMOTEXY_MODE__SOFTSERIAL
  2. #include <SoftwareSerial.h>
  3. #include <RemoteXY.h>
  4. #include "DHT.h"
  5.  
  6. // RemoteXY connection settings
  7. #define REMOTEXY_SERIAL_RX 8 // Bluetooth TX ---> Pin 8 Arduino
  8. #define REMOTEXY_SERIAL_TX 9 // Bluetooth RX ---> Pin 9 Arduino
  9. #define REMOTEXY_SERIAL_SPEED 38400
  10. #define DHTPIN 2 // DHT11 Data ---> Pin 2 Arduino
  11. #define PIN_BUTTON_1 13
  12. DHT dht(DHTPIN, DHT11);
  13.  
  14. // RemoteXY configurate
  15. #pragma pack(push, 1)
  16. uint8_t RemoteXY_CONF[] =
  17. { 255, 1, 0, 22, 0, 31, 0, 8, 13, 0,
  18. 1, 0, 10, 8, 12, 12, 2, 31, 88, 0,
  19. 67, 4, 34, 14, 20, 5, 2, 26, 11, 67,
  20. 4, 34, 30, 20, 5, 2, 26, 11
  21. };
  22.  
  23. // this structure defines all the variables of your control interface
  24. struct {
  25.  
  26. // input variable
  27. uint8_t button_1; // =1 if button pressed, else =0
  28.  
  29. // output variable
  30. char text_1[11]; // string UTF8 end zero
  31. char text_2[11]; // string UTF8 end zero
  32.  
  33. // other variable
  34. uint8_t connect_flag; // =1 if wire connected, else =0
  35.  
  36. } RemoteXY;
  37. #pragma pack(pop)
  38. void setup()
  39. {
  40. RemoteXY_Init ();
  41. pinMode (PIN_BUTTON_1, OUTPUT);
  42. pinMode (DHTPIN, INPUT);
  43. }
  44.  
  45. void loop()
  46. {
  47. RemoteXY_Handler ();
  48. digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1 == 0) ? LOW : HIGH);
  49. float temp = dht.readTemperature();
  50. float hum = dht.readHumidity();
  51. dtostrf(temp, 0, 1, RemoteXY.text_1);
  52. dtostrf(hum, 0, 1, RemoteXY.text_2);
  53. }
RAW Paste Data