I'm wanting to send data from 1 Arduino to another, in the fashion of 2 integers. (about to pull my hair out!)
When connected to my laptop serial monitor, I can send something like
100, 125
and it prints out on the screen. But I can't figure out how to send the 2 integers from another UNO. So I know it the sending UNO's syntax that's wrong. I've tried print, println, write, etc, but can't get it.
Receiving UNO
//runs on the arduino receiving the data
//incoming data is on hardware serial port
//outgoing data is on software serial port
#include <SoftwareSerial.h>
#include <MicroView.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
Serial.begin(57600);
mySerial.begin(57600);
uView.begin();
uView.clear(ALL); // erase hardware memory inside the OLED controller
uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared.
microViewPrint(12, 50);
}
void loop() {
if (Serial.available()) { //incoming data will be 2 integers: 100,150
int reading1 = Serial.parseInt();
int reading2 = Serial.parseInt();
if (Serial.read() == '\n') {
microViewPrint(reading1, reading2);
}
}
}
void microViewPrint(int i, int j) {
uView.clear(PAGE); //clear screen on mext display
uView.setFontType(1); //set font
uView.setCursor(0,0); //move cursor
uView.print(i);
uView.setCursor(0,10); //move cursor
uView.print(j);
uView.display(); //refresh screen
}
Sending UNO:
void setup() {
Serial.begin(57600);
}
void loop() // run over and over
{
for( int i=0; i<100; i++) {
Serial.print(i);
Serial.print(i+i);
delay(1000);
}
}