I’m trying to make a cell counter with arduino.
I want to get notification when ball1>10.
Please help me TT.
int cds=A2;
int fsr=A0;
int raser=A1;
int raser2=A3;
int led=12;
int emitter;
int total=0;
bool fault=false;
int force;
int temp;
int maxforce=0;
bool check=false;
bool check2=false;
int maxraser1;
int maxraser2;
int total2=0;
int ball1=0;
int ball2=0;
int ball3=0;
void outforce(); //
void outcds(); //
void outspeed(); //
#define BLYNK_PRINT Serial
#include "Timer.h"
#include <BlynkSimpleStream.h>
#include <SoftwareSerial.h>
#include "blynk.h"
#include <string.h>
Timer t;
void callMeLater() {
Blynk.virtualWrite(V0, ball1);
Blynk.virtualWrite(V3, total);
Blynk.virtualWrite(V1, ball2);
Blynk.virtualWrite(V2, ball3);
}
char auth[] = "3929b2efbddd4ba7ad379487b50f3eea";
SoftwareSerial SwSerial(2, 3); // RX, TX
void setup()
{ pinMode(cds, INPUT);
pinMode(fsr, INPUT); //
pinMode(raser, INPUT);
pinMode(raser2, INPUT);
SwSerial.begin(19200);
Serial.begin(19200);
Blynk.begin(SwSerial, auth); //
t.every(1000, callMeLater); //
}
void loop() {
outcds();
outforce();
outspeed();
Blynk.run();
t.update();
}
void outforce()
{
force=analogRead(fsr);
if(maxforce<=force)
{
maxforce=force;
}
if(force<10)
{
if(maxforce>=200 && maxforce<=400)
{
ball3=ball3+1;
}
else if(maxforce<800 && maxforce>500)
{
ball2=ball2+1;
}
else if(maxforce<=100 && maxforce>10)
{
ball1=ball1+1;
}
maxforce=0;
}
}
void outcds()
{
emitter=analogRead(cds);
if(emitter<400 && fault==false)
{
fault=true;
}
else if(emitter>400 && fault==true)
{
total++;
fault=false;
}
}
void outspeed()
{
int value=analogRead(raser);
int value2=analogRead(raser2);
if(maxraser1<=value)
{
maxraser1=value;
}
if(maxraser2<=value2)
{
maxraser2=value2;
}
if(maxraser1>60)
{
check=true;
}
if(maxraser2>60)
{
check2=true;
}
if(check==true && check2==true)
{
total2++;
check=false;
check2=false;
}
}