Browse Source

Update sensor code v1.1

master
cs161079 5 years ago
parent
commit
95fb9664fe
  1. 5
      sensorNode/sensor.ino

5
sensorNode/sensor.ino

@ -10,6 +10,7 @@
const int trigPin = 9; const int trigPin = 9;
const int echoPin = 10; const int echoPin = 10;
const int response = 6; const int response = 6;
const int id = 1;
// defines variables // defines variables
long duration; long duration;
@ -43,11 +44,11 @@ distance= duration*0.034/2;
//Serial.println(distance); //Serial.println(distance);
if (distance < 5){ if (distance < 5){
Serial.println("0"); //parking isn't available. Serial.println(id+"#0"); //parking isn't available.
digitalWrite(response, LOW); digitalWrite(response, LOW);
} }
else{ else{
Serial.println("1"); //parking is available. Serial.println(id+"#1"); //parking is available.
digitalWrite(response, HIGH); digitalWrite(response, HIGH);
} }

Loading…
Cancel
Save