our assignment this week was to design and program a smart device that perform a certain function or solve a problem ,while the arduino has to read from multiple inputs(sensors, switches,buttons..)and to control multiple action components (buzzer,led,motors...)
this week i decided to make a parking sensor device ,as its function is to sense the distance between the car and the obstacle using ultrasonic sensors , while indicating the distance by led lights or beeping sounds from a buzzer.
the software used to interpret the programing to arduino is arduino ide , and the software used to design the circuit is tinkercad
Arduino ide
tinkercad
white cardboard
the components used in this project are :
1 x buzzer
3 x 220 ampere resistor
1 x RGB LED lamp
1 x mini breadboard
1 x 5v adapter
1 x slide switch
15 x male\male electric wire jumpers
cardboard
Arduino Uno
for this assignment i wanted to make a parking sensor with two modes:
first mode is just a demonstration for the led light and the accompanying sound by the buzzer
second mode is for the sensing function with the ultra sonic sensor
first i designed the circuit with the Arduino for programing using tinkercad and assigned:
the buzzer to pin 9
the lRGB led to pins 6,5and3
trig to 11
echo to 10
led mode to 13
sensor mode to 12
the switch (which will be replaced by the tweezers ) to pin 7
circuit design
assembled circuit
i started writing the code by defining the pins numbers
then added the ultrasonic definition to the code
and defined which pins are input and which are output
i wrote for led mode to to turn the led colors in sequence just to demonstrate :
red and fast beeping sound mean the obstacle is close as (from 5 to 10 cm)
yellow and slow beeping sound mean the obstacle is as close as (from 10 to 20 cm)
green and slower beeping sound mean the obstacle is as close as (from 20 to 30 cm)
and for the sensor mode i added the equation to define the distance the ultrasonic reads and wrote on what distance the device should perform:
red and fast beeping sound mean the obstacle is close as (from 5 to 10 cm)
yellow and slow beeping sound mean the obstacle is as close as (from 10 to 20 cm)
green and slower beeping sound mean the obstacle is as close as (from 20 to 30 cm)
Arduino complete code:
code testing
first i added the code to arduino by using arduino ide then tested the circuit before installing in the housing
cardboard pieces
i made simple housing from cardboard and assembled with tape
final project
the functions for the slide switch were reversed instead of performing as intended, omar okasha adviced i turn the inputs into INPUT_PULLUP instead and it worked fine
i wanted to use the toggle switch we have in the kit , but when ever i used it the device lagged and couldn't perform the sensor mode , so i opted to not use it and to stick to the slide switch to save time
the skill i learnt this week will help me program two different modes into the arduino and how to switch between them
the coolest thing i learned is to be able to switch between modes in arduino, also i liked making a parking sensor ,i might design one for my self to use.