Browse Source

Sensor code V1.1

master
cs161079 5 years ago
parent
commit
1286b0bcae
  1. 9
      sensorNode/sensor/sensor.ino

9
sensorNode/sensor.ino → sensorNode/sensor/sensor.ino

@ -10,7 +10,7 @@
const int trigPin = 9;
const int echoPin = 10;
const int response = 6;
const int id = 1;
const int id = 2;
// defines variables
long duration;
@ -43,14 +43,17 @@ distance= duration*0.034/2;
//Serial.print("Distance: ");
//Serial.println(distance);
String park_out;
if (distance < 5){
Serial.println(id+"#0"); //parking isn't available.
park_out = String(id) + "#0"; //parking isn't available.
digitalWrite(response, LOW);
}
else{
Serial.println(id+"#1"); //parking is available.
park_out = String(id) + "#1"; //parking is available.
digitalWrite(response, HIGH);
}
Serial.println(park_out);
delay(500);
}
Loading…
Cancel
Save