Back to Parent

int presis=A0;
int led=D0;
int val=0;
int val2=0;
int buzzpin=D1;
int flagled=D2;
int flag=0;
int time1=0;

int time2=0;
void setup()
{
  pinMode(led, OUTPUT);
  pinMode(buzzpin, OUTPUT);
  pinMode(flagled, OUTPUT);
  Particle.variable("light",&val,INT);
  Particle.variable("light2",&val2,INT);
  Particle.variable("time10",&time1,INT);
  Particle.variable("time20",&time2,INT);
  time1=Time.now();
}

void loop()
{
  if (flag==0)
  {/*digitalWrite(led, HIGH);
  buzz();
  digitalWrite(led, LOW);*/
  val=analogRead(presis);
  val2=map(val,0,1000,0,255);
  analogWrite(led, val2);
  if (val2>800)
  {
    flag=1;
    time2=Time.now();
    //buzz();
    //digitalWrite(flagled, HIGH);
  }
  }
  else
  {
    buzz();
    digitalWrite(flag, HIGH);
  }
}

void buzz()
{
digitalWrite(led, LOW);
tone(buzzpin, 700,1500);
noTone(buzzpin);
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0