tutorial how create Artificial Intelligence safety solutions
Intro project:
AI can easily detect cars and give alerts to prevent accidents, thus compensating for human limitations. Basic ML algorithms can be used to track driving behavior and convert driving behavior into good driving scores.
AI and its Effect on Workplace Safety
IoT is a unique smart system that uses tiny sensors to monitor everything from individual machines to entire production lines, employees, and everything. Once the sensors are in place, the ML model monitors each individual element, identifies potential risks, and AI proposes solutions. Since AI has an impressive ability to predict future trends, it's able to pinpoint health risks and notify you before anything goes wrong.
You can set up predictive alerts and notifications throughout the entire system to minimize potential risks. Depending on the industry in question, such a system can save lives and prevent serious injuries.
Parts
Arduino uno r3
2 * HC-SR04
2 * Traffic Light LED Display Module
code:
#define trigPin 2 //sensor A
#define echoPin 3 //sensor A
#define btrigPin 7 //sensor B
#define bechoPin 8 //sensor B
#define LED 13
#define LED2green 12
long d1; // sensor 1 distance
long d2; // sensor 2 distance
long t1 = 0; // sensor 1 timestamp; initialize as 0
long t2 = 0; // sensor 2 timestamp; initialize as 0
unsigned long start_time; // time since program start
float max_distance = 10; // movement sensing range (in cm)
long sensor1=0;
long sensor2=0;
long sensorno=0;
void setup()
{
Serial.begin (115200);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(btrigPin, OUTPUT);
pinMode(bechoPin, INPUT);
pinMode(LED, OUTPUT);
pinMode(LED2green, OUTPUT);
start_time = millis(); // get program start time
}
void loop()
{
int walid=0;
int bduration, bdistance;
digitalWrite(btrigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(btrigPin, LOW);
bduration = pulseIn(bechoPin, HIGH);
bdistance = (bduration/2) / 29.1;
int duration, distance;
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance >= 3 && distance <= 10)
{
t1 = millis();
Serial.print(distance);
Serial.println(" cm");
sensor1=1;
if (t2 < t1)
{
// if left sensor triggered first
Serial.println("Left to right"); // direction is left to right
}
else if (t1 < t2)
{
// if right sensor triggered first
Serial.println("Right to left"); // direction is right to left
}
delay(1000);
}
else if (bdistance >= 3 && bdistance <= 10)
{
Serial.print(bdistance);
Serial.println(" cm");
t2 = millis();
sensor2=1;
if (t2 < t1)
{
// if left sensor triggered first
Serial.println("Left to right"); // direction is left to right
}
else if (t1 < t2)
{
// if right sensor triggered first
Serial.println("Right to left"); // direction is right to left
}
delay(1000);
}
if (sensor2==1 )
{
Serial.println("two");
Serial.println(sensor2);
Serial.println(sensor1);
digitalWrite(LED, HIGH);
digitalWrite(LED2green, LOW);
if (sensor1==1)
{
sensor1=0;
sensor2=0;
}
}
else if (sensor1==1)
{
Serial.println("one");
Serial.println(sensor2);
Serial.println(sensor1);
digitalWrite(LED, HIGH);
digitalWrite(LED2green, LOW);
if (sensor2==1)
{
sensor1=0;
sensor2=0;
}
}
else if (sensor2 ==0 && sensor1==0)
{
digitalWrite(LED, LOW);
digitalWrite(LED2green, HIGH);
}
delay(1000);
}