Update stable version 24/05/2025 #2

Merged
rafa merged 29 commits from dev into main 2025-05-24 20:00:44 +02:00
4 changed files with 15 additions and 12 deletions
Showing only changes of commit 517f012aa1 - Show all commits

View File

@ -21,6 +21,8 @@ class Barrier {
void configure_pins(){ void configure_pins(){
this->servo.attach(pin); this->servo.attach(pin);
this->servo.write(90);
this->state = CLOSED;
} }
void open(){ void open(){

View File

@ -24,13 +24,14 @@ class LCDScreen {
LCDScreen(String default_message = ""){ LCDScreen(String default_message = ""){
if (default_message != ""){ if (default_message != ""){
this->default_message = default_message; this->default_message = default_message;
this->state = DISPLAY_DEFAULT_MESSAGE;
} }
} }
void init(){ void init(){
lcd.init(); lcd.init();
lcd.backlight(); lcd.backlight();
this->display_default_message(); this->display_message(default_message);
} }
void clear(){ void clear(){
@ -48,7 +49,7 @@ class LCDScreen {
void display_default_message(){ void display_default_message(){
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(this->default_message); lcd.print(message);
} }
void display_parking_spots(int total_spots, int occupied_spots){ void display_parking_spots(int total_spots, int occupied_spots){

View File

@ -8,12 +8,14 @@
#include "CarSpotController.cpp"; #include "CarSpotController.cpp";
#include "JoyStickController.cpp"; #include "JoyStickController.cpp";
#define PARK_SLOTS 3
#define ULTRASONIC_SENSOR_PIN_TRIG 11 #define ULTRASONIC_SENSOR_PIN_TRIG 11
#define ULTRASONIC_SENSOR_PIN_ECHO 12 #define ULTRASONIC_SENSOR_PIN_ECHO 12
#define SERVO_PIN 10 #define SERVO_PIN 10
#define TEMP_SENSOR_PIN 9 #define TEMP_SENSOR_PIN 9
#define JOYSTICK_X_PIN A1 #define JOYSTICK_X_PIN A1
#define JOYSTICK_Y_PIN A0 #define JOYSTICK_Y_PIN A0
#define BUZZER_PIN 3
OneWire oneWire(TEMP_SENSOR_PIN); OneWire oneWire(TEMP_SENSOR_PIN);
DallasTemperature temperature_sensors(&oneWire); DallasTemperature temperature_sensors(&oneWire);
@ -39,7 +41,6 @@ void setup() {
void loop() { void loop() {
current_time = millis(); current_time = millis();
if (current_time - sensor_last_time_readed >= 1000){ if (current_time - sensor_last_time_readed >= 1000){
@ -50,7 +51,7 @@ void loop() {
barrier.open(); barrier.open();
car_spot_controller.increment_occupied_spots(); car_spot_controller.increment_occupied_spots();
}else{ }else{
tone(3, 262, 500); tone(BUZZER_PIN, 262, 500);
} }
} }
} else if (!dist_sensor.is_in_range() && barrier.is_open()){ } else if (!dist_sensor.is_in_range() && barrier.is_open()){
@ -60,6 +61,7 @@ void loop() {
} }
} }
if (current_time - temperature_last_time_measured >= 1000){ if (current_time - temperature_last_time_measured >= 1000){
temperature_last_time_measured = current_time; temperature_last_time_measured = current_time;
temperature_sensors.setWaitForConversion(false); temperature_sensors.setWaitForConversion(false);

View File

@ -3,7 +3,7 @@
"author": "Anonymous maker", "author": "Anonymous maker",
"editor": "wokwi", "editor": "wokwi",
"parts": [ "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-arduino-uno", "id": "uno", "top": -201, "left": -691.8, "attrs": {} },
{ {
"type": "wokwi-servo", "type": "wokwi-servo",
@ -13,13 +13,13 @@
"attrs": { "hornColor": "#FFFF00" } "attrs": { "hornColor": "#FFFF00" }
}, },
{ "type": "wokwi-hc-sr04", "id": "ultrasonic1", "top": -56.1, "left": -378.5, "attrs": {} }, { "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-ky-040", "id": "encoder1", "top": 164.9, "left": -711.2, "attrs": {} },
{ {
"type": "wokwi-pushbutton", "type": "wokwi-pushbutton",
"id": "btn1", "id": "btn1",
"top": 153.5, "top": 153,
"left": -514.9, "left": -515.4,
"rotate": 90, "rotate": 90,
"attrs": { "color": "yellow", "xray": "1", "bounce": "1" } "attrs": { "color": "yellow", "xray": "1", "bounce": "1" }
}, },
@ -48,8 +48,8 @@
{ {
"type": "wokwi-resistor", "type": "wokwi-resistor",
"id": "r1", "id": "r1",
"top": 225.6, "top": 227.2,
"left": 18.65, "left": 17.45,
"rotate": 90, "rotate": 90,
"attrs": { "value": "4700" } "attrs": { "value": "4700" }
}, },
@ -70,8 +70,6 @@
[ "uno:GND.2", "bb1:tn.1", "black", [ "v0" ] ], [ "uno:GND.2", "bb1:tn.1", "black", [ "v0" ] ],
[ "bb1:tn.50", "bb1:bn.50", "black", [ "h28", "v174" ] ], [ "bb1:tn.50", "bb1:bn.50", "black", [ "h28", "v174" ] ],
[ "bb1:tp.50", "bb1:bp.50", "red", [ "h37.6", "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:59b.j", "bb1:bp.48", "red", [ "v0" ] ],
[ "bb1:57b.j", "bb1:bn.46", "black", [ "v0" ] ], [ "bb1:57b.j", "bb1:bn.46", "black", [ "v0" ] ],
[ "encoder1:VCC", "bb1:bp.1", "red", [ "h57.6", "v58.9" ] ], [ "encoder1:VCC", "bb1:bp.1", "red", [ "h57.6", "v58.9" ] ],