Hi guys,
I'm trying to achieve a serial communication between 2 Arduino Nano (v3 - with micro-usb), over the USB connectors (micro-usb to micro-usb).
I've tested the code of both Arduinos, individually, with the Serial Monitor on the OS X. All good.
It seems Arduino - OS X via micro-usb works, but not the Arduino - Arduino.
I'm basically trying to send a char from one arduino and receive it on the other, using a micro-usb cable.
Found nothing online, I'm starting to think this might not be possible, which doesn't quite make sense.
Please let me know your thoughts
Receiver Arduino code:
int ledPin = LED_BUILTIN;
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);Serial.begin(115200);
}void loop() {
if (Serial.available()) {
char received = (char)Serial.read();
Serial.print(received);if (received == 'a') {
digitalWrite(ledPin, HIGH);
} else if (received == 'x') {
digitalWrite(ledPin, LOW);
}delay(1000);
}
}
Transmitter Arduino code:
int ledPin = LED_BUILTIN;
int buttonPin = 4;
char commandSent = '-';void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, LOW);Serial.begin(115200);
}void loop() {
if (digitalRead(buttonPin) == HIGH && commandSent != 'a') {
digitalWrite(ledPin, HIGH);
Serial.print('a');
Serial.write('a');
commandSent = 'a';
}
if (digitalRead(buttonPin) == LOW && commandSent != 'x') {
digitalWrite(ledPin, LOW);
Serial.print('x');
Serial.write('x');
commandSent = 'x';
}delay(10);
}
Thank you very much,
Marius