i did read it but am lil comfused
where do i need to place this
class CallbackClass
{
public:
void onTimeout();
}
CallbackClass callback;
void setup ()
or loop where?
and i this case do i need the library for SparkCorePolledTimer to add it inmy code or not
i would appreciate if u show me smiple example just to explian how to use it one time call.
this is my code just to understand what i maen
// This #include statement was automatically added by the Particle IDE.
#include <SparkCorePolledTimer.h>
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
// This #include statement was automatically added by the Particle IDE.
// Set Blynk hertbeat interval.
// Each heartbeat uses ~90 bytes of data.
#define BLYNK_HEARTBEAT 20000
// Set Particle keep-alive ping interval.
// Each ping uses 121 bytes of data.
//#define PARTICLE_KEEPALIVE 20000
#define LOCK D0
#define UNLOCK D1
#define TRUNK D2
#define PANIC D3
#define ENGINE_START D4
#define ARM D5
#define Engine_Status D6
SparkCorePolledTimer updateTimer(5000); //Create a timer object and set it's timeout in milliseconds
void OnTimer(void); //Prototype for timer callback method
SparkCorePolledTimer updateTimer1(60000); //Create a timer object and set it's timeout in milliseconds
void WordTittle(void);
int ENGINE_STATUS=0;
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin("xxx", IPAddress(45,55,130,102), 8442); // Here your Arduino connects to the Blynk Cloud.
updateTimer.SetCallback(OnTimer);
updateTimer1.SetCallback(WordTittle);
pinMode(LOCK,OUTPUT);
pinMode(UNLOCK,OUTPUT);
pinMode(TRUNK,OUTPUT);
pinMode(PANIC,OUTPUT);
pinMode(ENGINE_START,OUTPUT);
pinMode(ARM,OUTPUT);
pinMode(Engine_Status,INPUT);
digitalWrite(LOCK,HIGH);
digitalWrite(UNLOCK,HIGH);
digitalWrite(TRUNK,HIGH);
digitalWrite(PANIC,HIGH);
digitalWrite(ENGINE_START,HIGH);
digitalWrite(ARM,HIGH);
}
void WordTittle(void){
Blynk.virtualWrite(V8,"LOCK ");
Blynk.virtualWrite(V9,"UNLOCK ");
Blynk.virtualWrite(V10,"PANIC ");
Blynk.virtualWrite(V11,"TRUNK ");
Blynk.virtualWrite(V12,"ENGINE START ");
Blynk.virtualWrite(V13,"ARM/ACTIVE ");
}
void OnTimer(void) {
ENGINE_STATUS = digitalRead(Engine_Status);
if (ENGINE_STATUS == HIGH){
Blynk.virtualWrite(V7,"ENGINE ON ");
}
else {
Blynk.virtualWrite(V7,"ENGINE OFF ");
Blynk.notify("Engine Off");
}
}
// Lock
BLYNK_WRITE(V0) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(LOCK,LOW);
}
else if (state ==0)
{
digitalWrite(LOCK,HIGH);
}
}
//Unlock
BLYNK_WRITE(V1) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(UNLOCK,LOW);
}
else if (state ==0)
{
digitalWrite(UNLOCK,HIGH);
}
}
//Trunk
BLYNK_WRITE(V2) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(TRUNK,LOW);
}
else if (state ==0)
{
digitalWrite(TRUNK,HIGH);
}
}
//Panic
BLYNK_WRITE(V3) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(PANIC,LOW);
}
else if (state ==0)
{
digitalWrite(PANIC,HIGH);
}
}
// ENGINE_START
BLYNK_WRITE(V4) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(ENGINE_START,LOW);
}
else if (state ==0)
{
digitalWrite(ENGINE_START,HIGH);
}
}
// ARM /active
BLYNK_WRITE(V5) //Function to test status from BLYNK widget to PHOTON
{
int state = param.asInt();
if (state ==1)
{
digitalWrite(ARM,LOW);
Blynk.virtualWrite(V6,"CAR ARMED ");
}
else if (state ==0)
{
digitalWrite(ARM,HIGH);
Blynk.virtualWrite(V6,"CAR DISARMED ");
}
}
void loop()
{
Blynk.run();
updateTimer.Update();
}
am useing the this lib to update every seconds for the input
and that is uasing to much data
if i wanna just run it one time when i push the button
so it wont use much data
thanks