/* 0x00 0x00 0x00 0x00 0x00 0x00 0x5a 0x48 0x48 0x02 0x41 0x41 0x48 0x45 0x4C 0x4C 0x04 Green = RX Red = TX blue = GND */ #include <SoftwareSerial.h> SoftwareSerial mS(8, 9); // RX, TX //SoftwareSerial tS(9, 8); void setup() { Serial.begin(57600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } //mS.begin(9600, SERIAL_7N2); } void sendMessage( SoftwareSerial sS, int baudRate, char message[10]){ sS.begin( baudRate); sS.write( (byte)0); sS.write( (byte)0); sS.write( (byte)0); sS.write( (byte)0); sS.write( (byte)0); sS.write( (byte)0); sS.write( (byte)1); // start of header sS.write( (byte)'Z'); mS.write( (byte)'0'); mS.write( (byte)'0'); // sign code + sign id (zee zero zero) broadcast to all sS.write( (byte)2); //start of transmission //command sS.write( 'A'); mS.write('A'); //write and display message A sS.write('H'); sS.write('E'); sS.write('L'); sS.write('L'); sS.write('O'); sS.write( (byte)4); //end of transmissoin } void sendMessage1( SoftwareSerial sS, int baudRate, char message[10]){ sS.begin( baudRate); for(int i = 0; i < 7; ++i){ sS.write( (byte)0); } sS.write( (byte)1); // start of header sS.write( (byte)'Z'); mS.write( (byte)'0'); mS.write( (byte)'0'); // sign code + sign id (zee zero zero) broadcast to all sS.write( (byte)2); //start of transmission //command sS.write( 'A'); mS.write('A'); //write and display message A //sS.write( (byte)27); mS.write( ' '); //display line = center //sS.write( 'b'); //display mode = hold //message //mS.write( (byte)13); //the time sS.write(message[0]); //a message sS.write(message[1]); //a message sS.write(message[2]); //a message sS.write(message[3]); //a message sS.write(message[4]); //a message sS.write(message[5]); //a message sS.write(message[6]); //a message sS.write(message[7]); //a message sS.write(message[8]); //a message sS.write(message[9]); //a message sS.write( (byte)4); //end of transmissoin } void loop() // run over and over { if (mS.available()){ Serial.print(":"); Serial.println(mS.read()); } if (Serial.available()){ Serial.println("printing"); sendMessage(mS, 4800, "0123456789"); //sendMessage(tS, 4800, "0123456789"); sendMessage1(mS, 4800, "0123456789"); //sendMessage1(tS, 4800, "0123456789"); } delay(1500); }