Arduino Proj Network
Arduino Proj Network
h>
#include <SPI.h>
#include <SoftwareSerial.h>
int REDLed=2;
void setup() {
pinMode(REDLed, OUTPUT);
pinMode(GREENLed, OUTPUT);
pinMode(BLUELed, OUTPUT);
SIM900.begin(19200);
Serial.begin(19200);
Serial.print("power up" );
delay(10000);
digitalWrite(REDLed,HIGH);
digitalWrite(GREENLed,HIGH);
digitalWrite(BLUELed,HIGH);
}
void loop()
Serial.println("SubmitHttpRequest - started" );
SubmitHttpRequest();
Serial.println("SubmitHttpRequest - finished" );
delay(10000);
void SubmitHttpRequest()
delay(100);
ShowSerialData();// this code is to show the data from gprs shield, in order to easily see the process of
how the gprs shield submit a http request, and the following is for this purpose too.
delay(100);
ShowSerialData();
SIM900.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR, the connection type is
using gprs
delay(1000);
ShowSerialData();
delay(4000);
ShowSerialData();
delay(2000);
ShowSerialData();
delay(2000);
ShowSerialData();
SIM900.println("AT+CIPSEND=?");
delay(2000);
ShowSerialData();
SIM900.println("AT+HTTPREAD");// read the data from the website you access
delay(300);
changeLed();
ShowSerialData();
SIM900.println("");
delay(100);
void changeLed()
while(SIM900.available()!=0)
//Serial.write(SIM900.read());
Serial.println(content);
if(content.substring(28,29)== "1")
digitalWrite(REDLed, LOW);
{
digitalWrite(REDLed, HIGH);
if(content.substring(29,30)== "1")
digitalWrite(GREENLed, LOW);
digitalWrite(GREENLed, HIGH);
if(content.substring(30,31)== "1")
digitalWrite(BLUELed, LOW);
digitalWrite(BLUELed, HIGH);
char(SIM900.write("111"));
content = "";
void ShowSerialData()
{
while(SIM900.available()!=0)
Serial.write(char (SIM900.read()));
Serial.println(postRequest);
delay(1500);
countTrueCommand++;