Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define REMOTEXY_MODE__SOFTSERIAL
- #include <SoftwareSerial.h>
- #include <RemoteXY.h>
- #include "DHT.h"
- // RemoteXY connection settings
- #define REMOTEXY_SERIAL_RX 8 // Bluetooth TX ---> Pin 8 Arduino
- #define REMOTEXY_SERIAL_TX 9 // Bluetooth RX ---> Pin 9 Arduino
- #define REMOTEXY_SERIAL_SPEED 38400
- #define DHTPIN 2 // DHT11 Data ---> Pin 2 Arduino
- #define PIN_BUTTON_1 13
- DHT dht(DHTPIN, DHT11);
- // RemoteXY configurate
- #pragma pack(push, 1)
- uint8_t RemoteXY_CONF[] =
- { 255, 1, 0, 22, 0, 31, 0, 8, 13, 0,
- 1, 0, 10, 8, 12, 12, 2, 31, 88, 0,
- 67, 4, 34, 14, 20, 5, 2, 26, 11, 67,
- 4, 34, 30, 20, 5, 2, 26, 11
- };
- // this structure defines all the variables of your control interface
- struct {
- // input variable
- uint8_t button_1; // =1 if button pressed, else =0
- // output variable
- char text_1[11]; // string UTF8 end zero
- char text_2[11]; // string UTF8 end zero
- // other variable
- uint8_t connect_flag; // =1 if wire connected, else =0
- } RemoteXY;
- #pragma pack(pop)
- void setup()
- {
- RemoteXY_Init ();
- pinMode (PIN_BUTTON_1, OUTPUT);
- pinMode (DHTPIN, INPUT);
- }
- void loop()
- {
- RemoteXY_Handler ();
- digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1 == 0) ? LOW : HIGH);
- float temp = dht.readTemperature();
- float hum = dht.readHumidity();
- dtostrf(temp, 0, 1, RemoteXY.text_1);
- dtostrf(hum, 0, 1, RemoteXY.text_2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement