Created
June 12, 2014 15:11
-
-
Save anonymous/6c1c43beca7ae04cad74 to your computer and use it in GitHub Desktop.
This file contains 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 mySerial(2, 3); //RX, TX | |
//Ligando o Shield GSM SIM900. | |
int powerkey = 5; | |
int statuspin = 6; | |
int pinState = 0; | |
//Definindo Botao: | |
const int buttonPin = 13; | |
const int buttonPin2 = 12; | |
const int buttonPin3 = 11; | |
const int buttonPin4 = 10; | |
const int buttonPin5 = 9; | |
//Variavel de Apoio: | |
int buttonState = 100; | |
int buttonState2 = 102; | |
int buttonState3 = 103; | |
int buttonState4 = 104; | |
int buttonState5 = 105; | |
void setup() | |
{ | |
pinMode(buttonPin, INPUT); | |
pinMode(buttonPin2, INPUT); | |
pinMode(buttonPin3, INPUT); | |
pinMode(buttonPin4, INPUT); | |
pinMode(buttonPin5, INPUT); | |
pinMode(powerkey, OUTPUT); | |
pinMode(statuspin, INPUT); | |
//Serial Por Software Para o SIM900 Funcionar. | |
mySerial.begin(9600); | |
Serial.begin(9600); | |
//Delay Necessario Para o SIM900 Estabilizar. | |
delay(10000); | |
} | |
void loop() | |
{ | |
buttonState = digitalRead(buttonPin); | |
pinState = digitalRead(statuspin); | |
if(pinState==LOW){ | |
digitalWrite(powerkey, HIGH); | |
delay(2000); | |
digitalWrite(powerkey, LOW); | |
} | |
if (buttonState == HIGH) | |
{ | |
delay(20000); | |
mySerial.println("AT+CMGF=1"); | |
delay(200); | |
mySerial.print("AT+CMGS="); | |
mySerial.write(byte(34)); | |
mySerial.print("11974389125"); | |
mySerial.write(byte(34)); | |
mySerial.println(); | |
delay(200); | |
mySerial.print("A porta do motorista foi aberta."); | |
mySerial.write(byte(26)); | |
while(1); | |
} | |
if (buttonState2 == HIGH) | |
{ | |
delay(20000); | |
mySerial.println("AT+CMGF=1"); | |
delay(200); | |
mySerial.print("AT+CMGS="); | |
mySerial.write(byte(34)); | |
mySerial.print("11974389125"); | |
mySerial.write(byte(34)); | |
mySerial.println(); | |
delay(200); | |
mySerial.print("A porta do passageiro foi aberta."); | |
mySerial.write(byte(26)); | |
while(1); | |
} | |
if (buttonState3 == HIGH) | |
{ | |
delay(20000); | |
mySerial.println("AT+CMGF=1"); | |
delay(200); | |
mySerial.print("AT+CMGS="); | |
mySerial.write(byte(34)); | |
mySerial.print("11974389125"); | |
mySerial.write(byte(34)); | |
mySerial.println(); | |
delay(200); | |
mySerial.print("A porta de tras do motorista foi aberta."); | |
mySerial.write(byte(26)); | |
while(1); | |
} | |
if (buttonState4 == HIGH) | |
{ | |
delay(20000); | |
mySerial.println("AT+CMGF=1"); | |
delay(200); | |
mySerial.print("AT+CMGS="); | |
mySerial.write(byte(34)); | |
mySerial.print("11974389125"); | |
mySerial.write(byte(34)); | |
mySerial.println(); | |
delay(200); | |
mySerial.print("A de tras porta do passageiro foi aberta."); | |
mySerial.write(byte(26)); | |
while(1); | |
} | |
if (buttonState5 == HIGH) | |
{ | |
delay(20000); | |
mySerial.println("AT+CMGF=1"); | |
delay(200); | |
mySerial.print("AT+CMGS="); | |
mySerial.write(byte(34)); | |
mySerial.print("11974389125"); | |
mySerial.write(byte(34)); | |
mySerial.println(); | |
delay(200); | |
mySerial.print("O porta malas foi aberto."); | |
mySerial.write(byte(26)); | |
while(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment