.
Personal security is an important topic within transport. people with mobility impairments need extra time to cross a road. Smart traffic lights can help to improve the safety of vulnerable people.
.
I am going to implement a smart traffic light which will use AI technology to dynamically manage the safety of environment.
.
Original Idea.
My original idea was using the Yolo AI model to detect pedestrians on wheelchair crossing a road, the smart traffic light will dynamically manage the duration of the green light to improve the safety of such people.
.
I am going to use the Person Sensor in the project. Because of the privacy constraint, the Person Sensor does not support flashing the firmware or model updating.
.
.
With that, I need to change the original implementation. Instead I changed from disability detection (this requires model updating) to using traffic light switch (see image below) for specifically for disabled people.
.
Setup.
I followed the instructions in this tutorial (Collecting Sensor Data) to setup the Blue Swan wired up to Notecarrier A with a Notecard mounted. This tutorial (Swan Quickstart) shows how to setup the development using VS Code and PlatformIO extension.
.
Connecting Swan to Notecarrier A:
- Connect
V+
from the Notecarrier A to theUSB
pin on your Blues Swan. - Connect
GND
from the Notecarrier A to aGND
pin on your Blues Swan. - Connect
SDA
from the Notecarrier A to theSDA
pin on your Blues Swan. - Connect
SCL
from the Notecarrier A to theSCL
pin on your Blues Swan. - Attach the Swan to your computer with a Micro USB to USB-A cable, using the Micro USB port on the Swan.
.
For demo simulation, I used the LED light as the traffic light and push button as the traffic light switch for disabled people.
.
How It Works.
For the demo, when the traffic light switch is pressed by disabled people, the next duration of green light will be set to 5s so the the disabled people have enough time to cross the road. While the switch is not pressed, the duration will be set with a shorter duration of 1s. At the same time, the info such as push button status and green light duration will be sent and logged at the notehub.io for record keeping.
.
CodeHere is the code:
#include <Arduino.h>
#include <Wire.h>
#include <Notecard.h>
#define productUID "com.gmail.vincent.tsn:b2gapp1"
Notecard notecard;
int pressed = LOW;
int duration = 1000;
// the setup function runs once when you press reset or power the board
void setup()
{
Wire.begin();
Serial.begin(9600);
notecard.begin();
J *req = notecard.newRequest("hub.set");
JAddStringToObject(req, "product", productUID);
JAddStringToObject(req, "mode", "continuous");
JAddBoolToObject(req, "sync", true);
notecard.sendRequest(req);
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
pinMode(PE11, OUTPUT);
pinMode(PE9, INPUT_PULLUP); // push-to-make: pressed = LOW, not pressed = HIGH
}
// the loop function runs over and over again forever
void loop()
{
pressed = digitalRead(PE9);
Serial.println(pressed);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
// digitalWrite(PE11, HIGH);
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
// digitalWrite(PE11, LOW);
delay(1000); // wait for a second
if (pressed == LOW) {
digitalWrite(PE11, HIGH);
Serial.println(" pressed");
duration = 5000;
delay(5000);
}
else {
digitalWrite(PE11, LOW);
Serial.println(" not pressed");
duration = 1000;
delay(1000);
}
J *req = notecard.newRequest("note.add");
if (req != NULL)
{
JAddStringToObject(req, "file", "sensors.qo");
JAddBoolToObject(req, "sync", true);
J *body = JAddObjectToObject(req, "body");
if (body)
{
JAddNumberToObject(body, "ligth_duration", duration);
JAddBoolToObject(body, "button_pressed", pressed);
}
notecard.sendRequest(req);
Serial.println("data sent");
}
Serial.println("end loop");
}
.
Summary.
This project is a low tech implementation using push button and LED light, while the original idea was to use an AI model which can do disabilities detection and thus can help manage the safety of environment. In the future, i hope to implement this project using the more
.
Comments