Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited

Send Serial Data From Arduino Mega To Uno Using ARC

Hello
I can't wrap my head around how to send serial data from a Arduino Mega to a Arduino Uno USING ARC (2020-04-10)

Installing EZ-Mega-v1-636848729355769322.zip on the Mega and using ARC to talk to it works fine. (only done basic servo and LED control)
The Uno has just a standard Arduino sketch (See below for code)

The mega pins using 18-TX1 & 19-RX1 to Uno 0-RX & 1-TX with GND on both boards connected to each other.
I thought using

SendSerial(d18, 9600, "1")  - via ARC script, or "1" in the serial terminal

would send a 1 from the Mega to the Uno, to turn LED on/off
When sending command, the Mega (TX & RX flashes) Uno (RX flashes).
What else in ARC do I need to setup for this to work.?

Any help appreciated. 


NEW CODE ON UNO
* * * * * * * * * * * * * *
int led = 13;
void setup() {
pinMode(13,OUTPUT);
Serial.begin(9600);
Serial.flush();
}
void loop() {
while (Serial.available() >0) {
int input = Serial.read();
if (input == 1)
digitalWrite(led, HIGH);
else if (input == 2)
digitalWrite(led, LOW);
}
}



Using Mega as master and uno as slave (plain arduino setup) this code works fine via Arduino serial monitor.

Arduino MEGA (MASTER)
* * * * * * * * * * * * * * * *
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}

void loop() {
String readString;
String Q;
while (Serial1.available()){
delay(1);
if(Serial1.available()>0){
char c = Serial1.read();
Serial.print(c);
if (isControl(c)){
break;
}
}
}
while (Serial.available()) {
delay(1);
if (Serial.available() >0) {
char c = Serial.read();
if (isControl(c)) {
break;
}
readString += c;
}
}

Q = readString;
if(Q=="1"){
Serial1.print("1");
Serial.println("Sent:On");
}
if(Q=="2"){
Serial1.print("2");
Serial.println("Sent:Off");
}
}


Arduino UNO (Slave)
* * * * * * * * * * * * * * 
void setup() {
pinMode(13,OUTPUT);
Serial.begin(9600);
}

void loop() {
String readString;
String Q;

while (Serial.available()) {
delay(1);
if (Serial.available() >0) {
char c = Serial.read(); //gets one byte from serial buffer
if (isControl(c)) {
//'Serial.println("it's a control character");
break;
}
readString += c; //makes the string readString
}
}

Q = readString;
//--------Checking Serial Read----------
if(Q=="1"){
digitalWrite(13,HIGH);
}
if(Q=="2"){
digitalWrite(13,LOW);
}
}

Thanks Steve


Related Hardware Arduino Due/Mega
Related Control EZ-Script Console
AI Support Bot
Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
#1  
Well don't I feel stupid.

I stuck it in the wrong hole.

Don't you hate it when you do that :-(

All working now :-)