Omron HVC-P2 (Second Camera) icon Omron HVC-P2 (Second Camera) — Windows ARC plugin for Omron HVC-P/HVC-P2: Python-based face/body/hand detection, gaze, age/gender, expressions and recognition; dual-camera support. Try it →
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 (view all EZB hardware)
Arduino Mega with Synthiam ARCx controls 24 servos, 13 PWM, sensors and serial modules via EZB firmware over USB.
USB
Servos 24
Camera
Audio
UART 3
I2C
ADC 8
Digital 21

Related Robot Skill (view all robot skills)
Real-time EZ-Script console for ARC: enter and execute single-line commands, view output, clear display, and recall history with UP/DOWN.

ARC Pro

Upgrade to ARC Pro

ARC Pro is more than a tool; it's a creative playground for robot enthusiasts, where you can turn your wildest ideas into reality.

#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 :-)