Announcement

Collapse
No announcement yet.

Serial Communication between 4Duino and Arduino Mega

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Serial Communication between 4Duino and Arduino Mega

    Hello guys,

    i am trying to make a simple Serial communication between Arduino Mega and 4Duino, but it is not working.

    I have the Arduino Mega as Sender using this Code:

    Code:
    void setup() {
      Serial.begin(9600);
      Serial3.begin(9600);
    }
    
    void loop() {
      Serial.print('H');
      Serial3.print('H');
      delay(1000);
      Serial.print('L');
      Serial3.print('L');
      delay(1000);
    }
    And 4Duino as Receiver:

    Code:
    int incomingByte;
    
    void setup() {
      Serial.begin(9600);
    }
    
    void loop() {
      if (Serial.available() > 0) {
        incomingByte = Serial.read();
        if (incomingByte == 'H') {
          Serial.print('H');
        }
        if (incomingByte == 'L') {
          Serial.print('L');
        }
      }
    }
    As to the Connection i am using the pin D0(RX) / D1(TX) from 4Duino and the D14(TX3) / D15(RX3) from Arduino Mega.
    Linked TX3 to RX, TX to RX3 and GND to GND.

    Any ideas why it is not working?

    Thanks in advance.



  • #2
    d0 and d1 are wired to the picasso display onboard... youll need to use software serial on 4duino, or even better yet, AltSoftSerial for an extra serial port, if not you could go the i2c or spi route

    Comment


    • #3
      Originally posted by tonton81 View Post
      d0 and d1 are wired to the picasso display onboard... youll need to use software serial on 4duino, or even better yet, AltSoftSerial for an extra serial port, if not you could go the i2c or spi route
      Ok. Thanks. That is what I thught. I2C would be hard because I need the pins d20 and 21 from arching mega for the interrupts of my s function in MATLAB. I need all 6 available interrupts. In this case I will look for info on SPI and Software Serial communications.

      Or maybe connect them though i2c and use 2 interrupts on 4duino and 4 on arduino mega instead of all 6 on mega.

      Comment


      • #4
        altsoftserial may be beneficial, it uses a 16 bit timer and doesnt choke on tx bytes like softwareserial does. if you wanna try it use the pins mentioned under arduino leonardo, its same layout and cpu as 4duino, where altsoftserial works only on 2 pins of the board.

        serial would be better as you have full duplex, otherwise with i2c/spi you have to have a master and slave, but they can call one way to ask for data, unless you want to macguiver a pin signal to have the master check data. if you want more interrupts, there are better arduino boards than the mega, and quite frankly, i use mega only for testing. those other board have interrupt capability on all digital pins (depending on the board). so 52 digital pins == 52 interrupts, capable of nesting and priority interrupts as well (0-255) 0 being highest priority, 255 least

        Comment

        Working...
        X