0% found this document useful (0 votes)
10 views

New Text Document

The document contains code for an Arduino project that uses an ultrasonic distance sensor and LCD display to monitor distance and provide safety warnings. It flashes an LED and displays messages on the LCD like "STEP AWAY!!!" if an object gets too close. The code initializes the distance sensor pins, LED pin, and LCD, then continuously measures distance, displays it on the LCD, and triggers the warning behaviors if the distance is below a threshold.

Uploaded by

Muneeb Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

New Text Document

The document contains code for an Arduino project that uses an ultrasonic distance sensor and LCD display to monitor distance and provide safety warnings. It flashes an LED and displays messages on the LCD like "STEP AWAY!!!" if an object gets too close. The code initializes the distance sensor pins, LED pin, and LCD, then continuously measures distance, displays it on the LCD, and triggers the warning behaviors if the distance is below a threshold.

Uploaded by

Muneeb Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

the art of exploitation

************************************/////////************************************
metasploit the penetration tester's guide

****************************************88/////////**************************8
penetration testing
a hand on introduction to hacking///book black hat phyton
*********************************8//////////***********************************888
module traffic_control(
input wire north_road_in,
input wire east_road_in,
input wire south_road_in,
input wire west_road_in,
input wire clk,
input wire rst,
output reg [2:0] north_road_out,
output reg [2:0] east_road_out,
output reg [2:0] south_road_out,
output reg [2:0] west_road_out
);

reg [2:0] state;

parameter [2:0] north = 3'b000;


parameter [2:0] north_y = 3'b001;
parameter [2:0] east = 3'b010;
parameter [2:0] east_y = 3'b011;
parameter [2:0] south = 3'b100;
parameter [2:0] south_y = 3'b101;
parameter [2:0] west = 3'b110;
parameter [2:0] west_y = 3'b111;

reg [2:0] count;

reg [25:0] clkd = 26'b0;

always @(posedge clk)


clkd <= clkd + 1;

always @(posedge clkd[25] or posedge rst)


begin
if (rst)
begin
state <= north;
count <= 3'b000;
end
else
begin
case (state)
north:
begin
if (count == 3'b111)
begin
count <= 3'b000;
state <= north_y;
end
else
begin
count <= count + 3'b001;
state <= north;
end
end

north_y:
begin
if (count == 3'b011)
begin
count <= 3'b000;
state <= east;
end
else
begin
count <= count + 3'b001;
state <= north_y;
end
end

east:
begin
if (count == 3'b111)
begin
count <= 3'b0;
state <= east_y;
end
else
begin
count <= count + 3'b001;
state <= east;
end
end

east_y:
begin
if (count == 3'b011)
begin
count <= 3'b0;
state <= south;
end
else
begin
count <= count + 3'b001;
state <= east_y;
end
end

south:
begin
if (count == 3'b111)
begin
count <= 3'b0;
state <= south_y;
end
else
begin
count <= count + 3'b001;
state <= south;
end
end
south_y:
begin
if (count == 3'b011)
begin
count <= 3'b0;
state <= west;
end
else
begin
count <= count + 3'b001;
state <= south_y;
end
end

west:
begin
if (count == 3'b111)
begin
state <= west_y;
count <= 3'b0;
end
else
begin
count <= count + 3'b001;
state <= west;
end
end

west_y:
begin
if (count == 3'b011)
begin
state <= north;
count <= 3'b0;
end
else
begin
count <= count + 3'b001;
state <= west_y;
end
end
endcase
end
end

always @*
begin
case (state)
north:
begin
{north_road_out, east_road_out, south_road_out, west_road_out} = 4'b0010;
end

north_y:
begin
{north_road_out, east_road_out, south_road_out, west_road_out} = 4'b0100;
end
east:
begin
{north_road_out, east_road_out, south_road_out, west_road_out} = 4'b1000;
end

east_y:
begin
{north_road_out, east_road_out, south_road_out, west_road_out} = 4'b0010;
end

south:
begin
{north_road_out, east_road_out, south_road_out, west_road_out} = 4'b0100;
end

south_y:
begin
{north_road_out, east_road_out, south_road_out, west_road_out} = 4'b1000;
end

west:
begin
{north_road_out, east_road_out, south_road_out, west_road_out} = 4'b0100;
end
endcase
end

endmodule

*******************************************////////
**********************************

//Distance sensor
#define trigPin 12
#define echoPin 8

//Flashing LED on Arduino board


#define LEDPin 13

//LCD
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x20 // Define I2C Address where the PCF8574A is


#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

int n = 1;

LiquidCrystal_I2C lcd(0x27, 16,2);


void setup ()
{
Serial.begin(9600);
pinMode(trigPin, OUTPUT); //The transmit pin of the ultrasonic sensor
pinMode(echoPin, INPUT); //The receive pin of the ultrasonic sensor
pinMode(LEDPin, OUTPUT); //The LED of the Arduino

lcd.begin (20,4); //Size of LCD

// Switch on the backlight


lcd.init();
lcd.setBacklight(HIGH);
lcd.home (); // go home

void loop()
{
int duration, distance;
digitalWrite(trigPin, HIGH);
delayMicroseconds(100);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance =(duration/2) / 29.1;

lcd.clear();
lcd.setCursor(0,0);
lcd.print("Distance from OB");
lcd.setCursor(0,1);
lcd.print(distance);
lcd.print("cm");
if (distance >=10)
{
lcd.setCursor(0,4);
lcd.print("Safe Zone :)");
digitalWrite(LEDPin,HIGH);
delay(500);
digitalWrite(LEDPin,LOW);
delay(500);

}
else
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" STEP AWAY!!!");
lcd.setCursor(0,1);
lcd.print(" STEP AWAY!!!");
lcd.setCursor(0,2);
lcd.print(" STEP AWAY!!!");
lcd.setCursor(0,3);
lcd.print(" STEP AWAY!!!");
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);
delay(50);
digitalWrite(LEDPin,HIGH);
delay(50);
digitalWrite(LEDPin,LOW);

You might also like