Created
October 5, 2018 12:57
-
-
Save volodink/bc8caf9028f96227f9d1a6ddee2a42b4 to your computer and use it in GitHub Desktop.
gsmtest2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <SoftwareSerial.h> | |
| SoftwareSerial gsm(10, 11); // RX, TX | |
| SoftwareSerial gps(2, 3); // RX, TX | |
| char response[100]; | |
| void setup() { | |
| pinMode(5, OUTPUT); | |
| digitalWrite(5, LOW); | |
| delay(1000); | |
| digitalWrite(5, HIGH); | |
| delay(3000); | |
| digitalWrite(5, LOW); | |
| Serial.begin(9600); | |
| Serial.println("AI begin."); | |
| Serial.flush(); | |
| gsm.begin(9600); | |
| gsm.flush(); | |
| delay(1000); | |
| do { | |
| gsm.println("AT"); | |
| Serial.print("."); | |
| delay(500); | |
| } while (!gsm.find("OK")); | |
| delay(5000); | |
| gsm.println("AT+GPS=1"); | |
| delay(100); | |
| if (gsm.available()) | |
| while (gsm.available()) | |
| { | |
| Serial.print((char)gsm.read()); | |
| } | |
| delay(1000); | |
| gps.begin(9600); | |
| gps.flush(); | |
| delay(1000); | |
| pinMode(13, OUTPUT); | |
| } | |
| void loop() { | |
| digitalWrite(13, HIGH); | |
| delay(500); | |
| digitalWrite(13, LOW); | |
| delay(500); | |
| if (gps.available()) | |
| while (gps.available()) | |
| { | |
| Serial.print((char)gps.read()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment