-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbasic_arduino.ino
33 lines (26 loc) · 1003 Bytes
/
basic_arduino.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
// ------------------------------------------------------------
// Working with a GPS Module and an Arduino
// GPS Module: NEO-6M
// Arduino: Arduino Uno
// ------------------------------------------------------------
// Include the SoftwareSerial library to allow the Arduino to communicate with the GPS module.
#include <SoftwareSerial.h>
// Define the pins that will be used to communicate with the GPS module.
int RXPin = 4;
int TXPin = 3;
// Define the baud rate that will be used to communicate with the GPS module.
int GPSBaud = 9600;
// Create a new SoftwareSerial object called GPSSerial.
SoftwareSerial GPSSerial(RXPin,TXPin);
void setup() {
// Initialize the serial communication with the computer and the GPS module.
Serial.begin(9600);
GPSSerial.begin(9600);
}
void loop() {
// If the GPS module is connected and it's working, read and send the data to the computer.
while (GPSSerial.available() > 0) {
byte gpsData = GPSSerial.read();
Serial.write(gpsData);
}
}