Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <softwareserial.h>
- #define SIM800_TX_PIN 2 //SIM800 TX is connected to Arduino D2
- #define SIM800_RX_PIN 3 //SIM800 RX is connected to Arduino D3
- //Create software serial object to communicate with SIM800
- SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);
- int PWX = 4;
- void setup() {
- pinMode(PWX, OUTPUT);
- //Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
- Serial.begin(9600); //Begin serial communication with Arduino
- while(!Serial); //Monitor Comms on Arduino IDE (Serial Monitor)
- //Being serial communication with Arduino and SIM800
- serialSIM800.begin(9600);
- delay(1000);
- Serial.println("Setup Complete!");
- digitalWrite(PWX, HIGH);
- delay(3000);
- digitalWrite(PWX, LOW);
- delay(1000);
- Serial.println("Start");
- }
- void loop() {
- //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
- if(serialSIM800.available()){
- Serial.write(serialSIM800.read());
- }
- //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
- if(Serial.available()){
- serialSIM800.write(Serial.read());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement