Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SMS receiver
- // libraries
- #include <GSM.h>
- float desconto;
- float resul_desconto;
- // PIN Number
- #define PINNUMBER ""
- // initialize the library instance
- GSM gsmAccess; // include a 'true' parameter for debug enabled
- GSM_SMS sms;
- char remoteNumber[20]; // Holds the emitting number
- void setup()
- {
- // initialize serial communications
- Serial.begin(9600);
- Serial.println("SMS Concessiornaria");
- // connection state
- boolean notConnected = true;
- // Start GSM shield
- // If your SIM has PIN, pass it as a parameter of begin() in quotes
- while(notConnected)
- {
- if(gsmAccess.begin(PINNUMBER)==GSM_READY)
- notConnected = false;
- else
- {
- Serial.println("Não Conectado");
- delay(1000);
- }
- }
- Serial.println("GSM Inicializado");
- //Serial.println("Waiting for messages");
- }
- void loop()
- {
- char c;
- // If there are any SMSs available()
- if (sms.available())
- {
- Serial.println("Mensagem Recebida");
- // Get remote number
- sms.remoteNumber(remoteNumber, 20);
- Serial.println(remoteNumber);
- // This is just an example of message disposal
- // Messages starting with # should be discarded
- if(sms.peek()=='#')
- {
- //Serial.println("Discarded SMS");
- sms.flush();
- }
- // Read message bytes and print them
- Serial.println("Voce Recarregou (R$):");
- while(c=sms.parseInt())
- Serial.print(c);
- //Serial.println("\nEND OF MESSAGE");
- // delete message from modem memory
- sms.flush();
- //Serial.println("MESSAGE DELETED");
- // Desconto do valor da msg
- int resul = int (c);
- desconto = (resul-5);
- resul_desconto = resul_desconto + desconto;
- Serial.print("Valor recebido com 5 reais descontado: ");
- Serial.println(desconto,10);
- Serial.print("Valor acumulado: ");
- Serial.println(resul_desconto,10);
- }
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement