Tagged: Arduino
- AuthorPosts
Hi All,
I just bought a STWC043LT-01 5V version of this HMI and I am trying to connect it to Arduino. I followed this tutorial https://www.stoneitech.com/stone-hmi-with-arduino/but I was only able to get the Arduino to receive data. Does anyone know the pinout for the power board to be able to send data via the Arduino TXD? Also, I pasted my Arduino code below just in case there is a problem with it. Since I am able to receive data, I can successfully turn on and off LEDs through the HMI. I have set LED2 to send a HEX code back to the HMI to restart it once LED2 goes HIGH. That is where nothing happens. The HEX code is from the ASCII restart command found in the instruction sheet ST<{“cmd_code”:”sys_reboot”,”type”:”system”}>ET
Any help would be appreciated. Thank you.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1);
#define led1 2
#define led2 4int b = 0;
int Buffer[20];
int test[49] = {0X53, 0X54, 0X3C, 0X7B, 0X22, 0X63, 0X6D, 0X64, 0X5F, 0X63, 0X6F, 0X64, 0X65, 0X22, 0X3A, 0X22, 0X73, 0X79, 0X73, 0X5F, 0X72, 0X65, 0X62, 0X6F, 0X6F, 0X74, 0X22, 0X2C, 0X22, 0X74, 0X79, 0X70, 0X65, 0X22, 0X3A, 0X22, 0X73, 0X79, 0X73, 0X74, 0X65, 0X6D, 0X22, 0X7D, 0X3E, 0X45, 0X54};void setup()
{
Serial.begin(115200);
mySerial.begin(115200);
pinMode (led1, OUTPUT);
}void loop()
{
while (mySerial.available() > 0)
{
for (int i = 0; i <= 19; i++)
{
Buffer = mySerial.read();
Serial.print(Buffer, HEX);
Serial.print(” “);
}
Serial.println();
if (Buffer[19] == 0xB9)
{
analogWrite(led1, 0);
}
if (Buffer[19] == 0xB8)
{
analogWrite(led1, 255);
}
if (Buffer[19] == 0xFC)
{
analogWrite(led2, 255);
b = 255;
}
if (Buffer[19] == 0xFD)
{
analogWrite(led2, 0);
}
}if (analogRead(led2)&& b == 255)
{
for (int i = 0; i <= 48; i++)
{
mySerial.write(test);
Serial.println(test, HEX);
}
b=0;
}
}Hello. The file cannot be downloaded.
Please send your file rfid6.ino to the following email address.
sherry@stone-hmi.comThe code looks a little strange, are you using arudino uno, generally after the selection of development board do not add #include <SoftwareSerial.h>
Just use Arduino’s default Seial function interface
One more question, are you using the wrong function? Why not use digitalWrite and digitalRead if you just control the LED on and off?
- AuthorPosts
- You must be logged in to reply to this topic.