forked from MakersTeam/Galileo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoftwareSerial_GalileoGen2.ino
56 lines (41 loc) · 1.7 KB
/
SoftwareSerial_GalileoGen2.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
SoftwareSerial_GalileoGen2.ino - SoftwareSerial on GalileoGen2
Since the SoftwareSerial.h library is not supported in the Galileo board, this examples shows a
workaround of it. This sketch only works on Galileo Gen2.
Prior to run the sketch, the library SoftwareSerial_Class.h has to be imported.
Only pins 2 and 3 can be used for this purpose.
This example code is in the public domain.
Revision History
----------------------------------------------------------
Author Date Description
----------------------------------------------------------
Diego Villalobos 07-17-2015 Example created
*/
#include <SoftwareSerial_Class.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600); // The "Serial" object is for the Serial Monitor output.
Serial1.begin(9600); // The "Serial1" object is for the pins 0 and 1.
mySerial.begin(9600); // The "mySerial" object is for the pins 2 and 3.
}
void loop() // Run over and over
{
Serial.println("Sending from mySerial to Serial1...");
mySerial.println(0b00000000); // Sends data.
Serial.println("Receiving in Serial1 from mySerial...");
while(Serial1.available()){
Serial.println("Printing...");
Serial.println(Serial1.read(),DEC); // Data received and printed in the Serial Monitor.
}
delay (2500);
Serial.println("Sending from Serial1 to mySerial...");
Serial1.println(0b11111111); // Sends data.
Serial.println("Receiving in mySerial from Serial1...");
while(mySerial.available()){
Serial.println("Printing...");
Serial.println(mySerial.read(),DEC); // Data received and printed in the Serial Monitor.
}
delay (2500);
}