Results 1 to 2 of 2

Thread: Arduino due Serial communication trouble

  1. #1
    manu Guest

    Question Arduino due Serial communication trouble

    Hi,




    I have been trying this simple programme that i got from your site to send data from an arduino due to an atmega328:i was using the following code:
    Arduino:
    Code:
    void setup() {
       Serial.begin(9600); 
       
    }
    void loop()
    {
      Serial.println("hello"); 
      Serial.println('h'); 
    }

    atmega:
    Code:
    int incomingByte = 0; // for incoming serial data
    
    
    void setup() {
    Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
    }
    
    
    void loop() {
    
    
    // send data only when you receive data:
    if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();
    
    
    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte,DEC);
    }
    }

    while this worked perfectly, when i modified the code a little as follows, i did not get the expected results:
    arduino:
    Code:
    void setup() {
       Serial.begin(9600); 
       
    }
    void loop()
    {
      Serial.println('a');  
      Serial.println('b');  
    }

    atmega:
    Code:
    int incomingByte = 0; // for incoming serial data
    
    
    void setup() {
    Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
    }
    
    
    void loop() {
    
    
    // send data only when you receive data:
    if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();
    
    
    if(incomingByte =='a')
     {
        Serial.println("a");
     }
    else if (incomingByte =='b')
     {
        Serial.println("b");
     }
    else
     {
        Serial.println("d");
     }
    }



    Please help!!!!!!! :~

  2. #2

    Re: Arduino due Serial communication trouble

    I'm assuming that by 'atmega' you mean Arduino Due?
    You'll need to tell us how you wired up the units, and what 'did not get the expected results' means - did anything happen at all? Does the due/atmega work when you send it data via the serial monitor?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Serial communication between Arduino and Arbotix
    By dburongarcia in forum Arbotix, Microcontrollers, Arduino
    Replies: 17
    Last Post: 03-09-2014, 12:44 PM
  2. Question(s) AX-12 controled by Serial communication
    By tailer in forum Arbotix, Microcontrollers, Arduino
    Replies: 3
    Last Post: 11-17-2012, 11:19 AM
  3. Question(s) RAW Serial Communication
    By ilo_oli in forum Software and Programming
    Replies: 5
    Last Post: 11-01-2011, 05:38 PM
  4. Question(s) RoboRealm and Axon serial communication issues
    By Resilient in forum Software and Programming
    Replies: 2
    Last Post: 05-15-2009, 04:06 AM
  5. C++ Serial Communication
    By Resilient in forum Software and Programming
    Replies: 14
    Last Post: 02-03-2009, 03:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •