Guest User

GSM Sketch

a guest
Jul 21st, 2014
224
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SoftwareSerial.h>  
  2. char var = 0;
  3.  
  4. SoftwareSerial gsmSerial(2,3);
  5.  
  6. void setup()
  7. {
  8.     Serial.begin(9600);
  9.     gsmSerial.begin(9600);
  10.     Serial.println("Starting Communication...");
  11. }
  12.  
  13. void loop() {
  14.   if(gsmSerial.available() > 0){
  15.     var = gsmSerial.read();
  16.     Serial.print(var);
  17.   }
  18.  
  19.   if(Serial.available() > 0){
  20.     var = Serial.read();
  21.    
  22.     if(var == 't'){
  23.       gsmSerial.print("AT\r");
  24.     } else if(var == 'p'){
  25.       gsmSerial.print("AT+CPIN=****\r");
  26.     } else if(var == 'g'){
  27.       gsmSerial.print("AT+CMGF=1\r");
  28.     } else if(var == 's'){
  29.       gsmSerial.print("AT+CMGS=+43*********\r");
  30.       delay(100);
  31.       gsmSerial.print("Hallo Welt :) \r");
  32.       delay(10);
  33.       gsmSerial.print("\x1A");
  34.     } else if(var == 'x'){
  35.       gsmSerial.print("AT+CMGL\r");
  36.     }
  37.   }
  38. }
RAW Paste Data