Go Down

Topic: Uno: SoftwareSerial -> to -> Due: HardwareSerial? (Read 737 times) previous topic - next topic

jeglenn

I have some code running on the Uno using 'software serial' for doing MIDI on and Adafruit MusicMaker sheild.  I want to move it over to a Due, but there is not Software Serial library for the Due.   So for some reason I don't know what to do that.  (I feel like this is a very stupid question).

For the Uno code I have:
<clip>
#include <SoftwareSerial.h>
<clip>
SoftwareSerial VS1053_MIDI(0, 2); // using pin2 for transmit

For the Due code I want??
#include <HardwareSerial.h>
Serial2 VS1053_MIDI; // hardware serial pins pre-defined hard-wired pins.

Clearly my Due code isn't correct...

Thanks,
Joe

lonas

There is software serial for DUE and usage is the same as on uno.

If You want to define hardware serial - just do:

Code: [Select]

void setup() {
Serial.begin(19200);
}

void loop() {
  Serial.println("hello world");
}

jeglenn

Thanks.  I realized that, first, my Serial2 line didn't make sense.  (Because Serial2 is not a type).  And the quick fix to my issue was to use a #define to make VS1053_MIDI point to Serial2.  The the rest of the code didn't need to be re-written.

So...

#include <HardwareSerial.h>
#define VS1053_MIDI Serial1 // hardware serial pins pre-defined hard-wired pins, in the case pin 18.

I also needed this:

#define VS1052_RX 18 // the pin number is needed in the Adafruit exmaple code.

Works great!

Go Up