Add seond sensor

This commit is contained in:
Dennis Schoepf 2020-09-17 15:32:46 +02:00
parent 6db53bfdee
commit 039e4758f1

View file

@ -1,22 +1,33 @@
#include <Arduino.h>
#include <SharpIR.h>
SharpIR sensor(SharpIR::GP2Y0A02YK0F, A0);
SharpIR sensorProx(SharpIR::GP2Y0A02YK0F, A0);
SharpIR sensorDown(SharpIR::GP2Y0A02YK0F, A1);
void setup()
{
Serial.begin(9600);
pinMode(A0, INPUT);
// put your setup code here, to run once:
pinMode(A1, INPUT);
}
void loop()
{
int distance = sensor.getDistance();
int distanceProx = sensorProx.getDistance();
int distanceDown = sensorDown.getDistance();
Serial.print("Proximity");
Serial.println(distanceProx);
Serial.print("Down");
Serial.println(distanceDown);
delay(100);
if (distance < 40)
if (distanceProx < 40)
{
Serial.println("isWithinThreshhold");
Serial.println("Through first barrier");
}
if (distanceDown < 35)
{
Serial.println("Through second barrier");
}
delay(100);
}