-2

I would like to establish a serial communication between two Arduino and I wrote the following test code.

Receiver Arduino sketch:

void setup() {

 Serial.begin(4800,SERIAL_8E1);
}

void loop() {

Serial.println(0,BIN);

Serial.println(10000000,BIN);

Serial.println(11000000,BIN);

}

Sender Arduino sketch:

void setup() {

 Serial.begin(4800,SERIAL_8E1);
}

void loop() {

Serial.println(0,BIN);

Serial.println(10000000,BIN);

Serial.println(11000000,BIN);

}

Then,

I sent:

0

10000000

11000000

But "Receiver Arduino" receive

I received: 11001100

I received: 100

I received: 100

I received: 100

I received: 10110

I received: 100

I received: 100

I received: 100

I received: 100

I received: 100

I received: 100

How can I revise it?

closed as unclear what you're asking by VE7JRO, sempaiscuba, per1234, Juraj, gre_gor Jan 10 at 12:09

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Sender and Receiver code are exactly the same. You don't read any serial data. Are you sure, you posted the correct code? Also please format it correctly by pasting it, then selecting the code and clicking the {} button in the editors toolbar. – chrisl Jan 8 at 6:09
  • 3
    Serial.println(10000000,BIN) prints decimal 10000000 as binary. so your code in question doesn't match your output – Juraj Jan 8 at 9:29
-1
void loop(){
  if (Serial.available()>0){ // check if have data
  Serial.println (Serial.read(), BIN);  //read the data and print it
  }
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.