Explain me what this code does
hello everybody!
im new arduino , programming regarding it. have code alarm system made , works perfect, need understanding actual code because ive put pieces, examples, tutorials , on. kinda know c/c++ programming arduino little different , knowledge of 2 languages isn't perfect either. maybe enlighten me , explain me how code put , in every section?
i very thankful!
im new arduino , programming regarding it. have code alarm system made , works perfect, need understanding actual code because ive put pieces, examples, tutorials , on. kinda know c/c++ programming arduino little different , knowledge of 2 languages isn't perfect either. maybe enlighten me , explain me how code put , in every section?
i very thankful!
code: [select]
#include "sim900.h"
#include <softwareserial.h>
#include "sms.h"
#include "sodaq_ds3231.h"
#include <wire.h>
smsgsm sms;
string smstext = "movement at ";
boolean started=false;
char sms_text[160];
int ledpin = 13;
int pirpin = 7;
int val = 0;
void setup()
{
wire.begin();
rtc.begin();
pinmode (ledpin,output);
pinmode (pirpin, input);
serial.begin(3000);
if (gsm.begin(3000))
{
serial.println("\nstatus=ready");
started=true;
}
else
serial.println("\nstatus=idle");
}
void loop ()
{
string timestamp;
val = digitalread(pirpin);
digitalwrite(ledpin,val);
if (val == 1)
{
timestamp = getdatetime();
serial.println(timestamp);
smstext = smstext+timestamp;
smstext.tochararray(sms_text,160);
sms.sendsms("number",sms_text); //insert phone number here!!!
string smstext = "movement @ ";
delay(2000);
}
}
string getdatetime()
{
datetime = rtc.now(); //gets real time
string timestring;
string hourstring;
string minutestring;
if(now.hour() <10)
{
hourstring = "0"+string(now.hour());
}else
{
hourstring = string(now.hour());
}
if(now.minute() <10)
{
minutestring = "0"+string(now.minute());
}else
{
minutestring = string(now.minute());
}
timestring = hourstring+":"+minutestring+" "+string(now.month())+"/"+string(now.date())+"/"+string(now.year());
return timestring;
}
quote
. kinda know c/c++ programming arduino little differentno, it's c++.
you've got strange serial line speeds there
Arduino Forum > Using Arduino > Programming Questions > Explain me what this code does
arduino
Comments
Post a Comment