Update stable version 24/05/2025 #2
@ -21,6 +21,8 @@ class Barrier {
|
||||
|
||||
void configure_pins(){
|
||||
this->servo.attach(pin);
|
||||
this->servo.write(90);
|
||||
this->state = CLOSED;
|
||||
}
|
||||
|
||||
void open(){
|
||||
|
||||
@ -24,13 +24,14 @@ class LCDScreen {
|
||||
LCDScreen(String default_message = ""){
|
||||
if (default_message != ""){
|
||||
this->default_message = default_message;
|
||||
this->state = DISPLAY_DEFAULT_MESSAGE;
|
||||
}
|
||||
}
|
||||
|
||||
void init(){
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
this->display_default_message();
|
||||
this->display_message(default_message);
|
||||
}
|
||||
|
||||
void clear(){
|
||||
@ -48,7 +49,7 @@ class LCDScreen {
|
||||
void display_default_message(){
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print(this->default_message);
|
||||
lcd.print(message);
|
||||
}
|
||||
|
||||
void display_parking_spots(int total_spots, int occupied_spots){
|
||||
|
||||
@ -8,12 +8,14 @@
|
||||
#include "CarSpotController.cpp";
|
||||
#include "JoyStickController.cpp";
|
||||
|
||||
#define PARK_SLOTS 3
|
||||
#define ULTRASONIC_SENSOR_PIN_TRIG 11
|
||||
#define ULTRASONIC_SENSOR_PIN_ECHO 12
|
||||
#define SERVO_PIN 10
|
||||
#define TEMP_SENSOR_PIN 9
|
||||
#define JOYSTICK_X_PIN A1
|
||||
#define JOYSTICK_Y_PIN A0
|
||||
#define BUZZER_PIN 3
|
||||
|
||||
OneWire oneWire(TEMP_SENSOR_PIN);
|
||||
DallasTemperature temperature_sensors(&oneWire);
|
||||
@ -39,7 +41,6 @@ void setup() {
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
current_time = millis();
|
||||
|
||||
if (current_time - sensor_last_time_readed >= 1000){
|
||||
@ -50,7 +51,7 @@ void loop() {
|
||||
barrier.open();
|
||||
car_spot_controller.increment_occupied_spots();
|
||||
}else{
|
||||
tone(3, 262, 500);
|
||||
tone(BUZZER_PIN, 262, 500);
|
||||
}
|
||||
}
|
||||
} else if (!dist_sensor.is_in_range() && barrier.is_open()){
|
||||
@ -60,6 +61,7 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (current_time - temperature_last_time_measured >= 1000){
|
||||
temperature_last_time_measured = current_time;
|
||||
temperature_sensors.setWaitForConversion(false);
|
||||
|
||||
14
diagram.json
14
diagram.json
@ -3,7 +3,7 @@
|
||||
"author": "Anonymous maker",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{ "type": "wokwi-breadboard", "id": "bb1", "top": 72.2, "left": -524, "attrs": {} },
|
||||
{ "type": "wokwi-breadboard", "id": "bb1", "top": 73.8, "left": -525.2, "attrs": {} },
|
||||
{ "type": "wokwi-arduino-uno", "id": "uno", "top": -201, "left": -691.8, "attrs": {} },
|
||||
{
|
||||
"type": "wokwi-servo",
|
||||
@ -13,13 +13,13 @@
|
||||
"attrs": { "hornColor": "#FFFF00" }
|
||||
},
|
||||
{ "type": "wokwi-hc-sr04", "id": "ultrasonic1", "top": -56.1, "left": -378.5, "attrs": {} },
|
||||
{ "type": "board-ds18b20", "id": "temp1", "top": 94.87, "left": 32.88, "attrs": {} },
|
||||
{ "type": "board-ds18b20", "id": "temp1", "top": 96.47, "left": 31.68, "attrs": {} },
|
||||
{ "type": "wokwi-ky-040", "id": "encoder1", "top": 164.9, "left": -711.2, "attrs": {} },
|
||||
{
|
||||
"type": "wokwi-pushbutton",
|
||||
"id": "btn1",
|
||||
"top": 153.5,
|
||||
"left": -514.9,
|
||||
"top": 153,
|
||||
"left": -515.4,
|
||||
"rotate": 90,
|
||||
"attrs": { "color": "yellow", "xray": "1", "bounce": "1" }
|
||||
},
|
||||
@ -48,8 +48,8 @@
|
||||
{
|
||||
"type": "wokwi-resistor",
|
||||
"id": "r1",
|
||||
"top": 225.6,
|
||||
"left": 18.65,
|
||||
"top": 227.2,
|
||||
"left": 17.45,
|
||||
"rotate": 90,
|
||||
"attrs": { "value": "4700" }
|
||||
},
|
||||
@ -70,8 +70,6 @@
|
||||
[ "uno:GND.2", "bb1:tn.1", "black", [ "v0" ] ],
|
||||
[ "bb1:tn.50", "bb1:bn.50", "black", [ "h28", "v174" ] ],
|
||||
[ "bb1:tp.50", "bb1:bp.50", "red", [ "h37.6", "v174" ] ],
|
||||
[ "bb1:bn.2", "bb1:4b.j", "black", [ "v0" ] ],
|
||||
[ "bb1:2t.b", "uno:8", "gold", [ "v-240", "h-19.2", "v-86.4" ] ],
|
||||
[ "bb1:59b.j", "bb1:bp.48", "red", [ "v0" ] ],
|
||||
[ "bb1:57b.j", "bb1:bn.46", "black", [ "v0" ] ],
|
||||
[ "encoder1:VCC", "bb1:bp.1", "red", [ "h57.6", "v58.9" ] ],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user