المكونات الاساسية :
- Arduino UNO
- relay 5v module 2 channel
- bluetooth HC-05
- 220v Lamp
- jumper wires
- smartphone
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600
#define REMOTEXY_ACCESS_PASSWORD "123456"
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,2,0,0,0,78,0,10,13,0,
2,0,7,23,33,14,2,26,31,31,
79,78,0,79,70,70,0,129,0,10,
5,80,11,36,67,111,110,116,114,111,
108,32,50,32,76,97,109,112,0,129,
0,23,49,54,8,109,68,73,89,32,
67,72,65,78,78,69,76,0,2,0,
54,23,34,14,134,26,31,31,79,78,
0,79,70,70,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t switch_1; // =1 if switch ON and =0 if OFF
uint8_t switch_2; // =1 if switch ON and =0 if OFF
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define PIN_SWITCH_1 11
#define PIN_SWITCH_2 10
void setup()
{
RemoteXY_Init ();
pinMode (PIN_SWITCH_1, OUTPUT);
pinMode (PIN_SWITCH_2, OUTPUT);
// TODO you setup code
}
void loop()
{
RemoteXY_Handler ();
digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
digitalWrite(PIN_SWITCH_2, (RemoteXY.switch_2==0)?LOW:HIGH);
// TODO you loop code
// use the RemoteXY structure for data transfer
// do not call delay()
}
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600
#define REMOTEXY_ACCESS_PASSWORD "123456"
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,2,0,0,0,78,0,10,13,0,
2,0,7,23,33,14,2,26,31,31,
79,78,0,79,70,70,0,129,0,10,
5,80,11,36,67,111,110,116,114,111,
108,32,50,32,76,97,109,112,0,129,
0,23,49,54,8,109,68,73,89,32,
67,72,65,78,78,69,76,0,2,0,
54,23,34,14,134,26,31,31,79,78,
0,79,70,70,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t switch_1; // =1 if switch ON and =0 if OFF
uint8_t switch_2; // =1 if switch ON and =0 if OFF
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define PIN_SWITCH_1 11
#define PIN_SWITCH_2 10
void setup()
{
RemoteXY_Init ();
pinMode (PIN_SWITCH_1, OUTPUT);
pinMode (PIN_SWITCH_2, OUTPUT);
// TODO you setup code
}
void loop()
{
RemoteXY_Handler ();
digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
digitalWrite(PIN_SWITCH_2, (RemoteXY.switch_2==0)?LOW:HIGH);
// TODO you loop code
// use the RemoteXY structure for data transfer
// do not call delay()
}
No comments:
Post a Comment