Answer the question
In order to leave comments, you need to log in
Who can help with arduino code?
Good afternoon. I don't know much about arduino, I do everything according to the lessons. I assembled a schematic of a smart socket ( tyk if you're interested ). The problem is that when the assembly is connected to the network, the relay is immediately powered, that is, the sockets are powered.
Code:
///////////////////////////////////////////
// RemoteXY include library //
// use ANDROID app version 3.1.1 or up //
///////////////////////////////// ////////////
/* defining the connection mode and connecting the RemoteXY library */
#define REMOTEXY_MODE__SOFTWARESERIAL
#include
#include
/* connection settings */
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600
/* interface configuration */
unsigned char RemoteXY_CONF[] =
{ 2,0,30,0,2,5,2,0,6,2
,88,29,1,79,78,0,79 ,70,70,0
,2,0,6,33,88,29,6,79,78,0
,79,70,70,0 };
/* struct defines all variables of your control interface */
struct {
/* input variable */
unsigned char switch_1; /* =1 if switch is enabled and =0 if disabled */
unsigned char switch_2; /* =1 if switch is enabled and =0 if disabled */
/* other variable */
unsigned char connect_flag; /* =1 if wire connected, else =0 */
} RemoteXY;
////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////// //
#define PIN_SWITCH_1 4
#define PIN_SWITCH_2 5
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 to pass data
}
Changed in void setup()
digitalWrite(PIN_SWITCH_1, 1);
digitalWrite(PIN_SWITCH_2, 1);
and
digitalWrite(PIN_SWITCH_1, 0);
digitalWrite(PIN_SWITCH_2, 0);
The relay turns off, but the device does not respond to a signal from the phone. When coding, a library is used. (If necessary, I can throw)
How can I change the code so that when turned on, the relay was not active? Thank you in advance)
Answer the question
In order to leave comments, you need to log in
try changing
digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
digitalWrite(PIN_SWITCH_2, (RemoteXY.switch_2==0)?LOW:HIGH);
to
digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?HIGH:LOW);
digitalWrite(PIN_SWITCH_2, (RemoteXY.switch_2==0)?HIGH:LOW);
and after
pinMode(PIN_SWITCH_1, OUTPUT);
pinMode(PIN_SWITCH_2, OUTPUT);
add
digitalWrite(PIN_SWITCH_1, LOW);
digitalWrite(PIN_SWITCH_2, LOW);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question