the idea of this week's assignment is to make the circuit of my final project ( flipbook kit ) to experiment with it and to see what I should improve, remove or add to my idea.
SO:
the idea is to use an ultrasonic sensor with DC motor, L293D pushbutton, and led ( pushbutton is the input ) that when I push it the sensor, motor and the led will turn on ( and this will happen when someone is close to the sensor or the kit less than or equals to 50 cm.
so the project will run as follows:
the push button or the on/off switch is the input of the circuit ( project ) and by clicking on them they will make anything in the circuit run or stop.
the ultrasonic sensor is the input that will make the dc motor rotate and the led lights ( which are the outputs ) when someone is close to the ultrasonic sensor less than or equals 50 cm, and all of that by the permission from the push button or the on/off switch ( because I made one circuit with push-button and another with on/off switch).
the Image that expresses what I mean
it will flip like this when someone close to it by user's permission from a pushbutton
I used TINKERCAD software to design the circuit and to make the code blocks for it, and after making the circuit on TINKERCAD, I used the real circuit and Arduino Uno to apply the same circuit in reality, I also used Arduino software to import the code text from TINKERCAD to Arduino and from Arduino software to the real Arduino slice.
the electronic components that I used:
ultrasonic sensor, DC motor, l293D with led and push-button with (220Ω resistors) to control all of that I also used a power source ( 9v ), breadboard, Arduino Uno, and jumper wires to connect between breadboard, Arduino, pushbutton, LED, motor, L293D, and the ultrasonic sensor I also used crocodile wires for the on/off switch.
note: I made 2 versions one with push-button and the other with an on/off switch.
TINKERCAD software app that I used to design the circuit
Arduino software that I used to import the code to the real Arduino slice
firstly,
I started to design the circuit that I want for my final project at TINKERCAD so I used the ultrasonic sensor, DC motor, l293D with led and push-button with (220Ω resistors) to control all of that I also used a power source ( 9v ), breadboard, Arduino Uno and jumper wires to connect between breadboard, Arduino, pushbutton, LED, motor, L293D, and ultrasonic sensor I also used crocodile wires for the on/off switch so:
at first, I put the L293D on the breadboard then I started to connect the dc motor with it and the Arduino Uno so I connect ( the two outputs from the DC motor to the l293D on the circuit then I connect the l293d input wires to the Arduino Uno digital pins which are ( 3&4 pins ) and those pins control the rotation direction of the motor, after that, I connect the pin that enables the movement of the motor from the L293D to the Arduino Uno ( pin 5 ) . then I connect the breadboard positive section to the Arduino power ( 5V) and the negative section to the Arduino ground so the breadboard positive and negative pin are now connected to the Arduino. then I connect the L293D power to a breadboard positive pin section and the L293D ground to a breadboard negative pin section.
then I started to connect another power source with ( 9V ) to could move the DC motor and I connected the positive part to the L293D enable pin and the negative part to the breadboard negative pin section.
after that, I started to connect the ultrasonic sensor so I connected its ACC to a positive pin section on a breadboard and its GND to the Arduino's GND then connected the trig to Arduino's ( pin 6 ) and the echo to Arduino's ( pin7).
then I connected the negative LED leg to (220Ω) resistor to a breadboard negative section and the positive leg to Arduino's ( pin 8 ).
I also connected the push button to legs one with the ( 220Ω ) resistor to a breadboard negative section and the other leg to the Arduino's ( pin 2).
I also try the same circuit with the on/off switch instead of the push button so I connected the on/off switch with two crocodile wires and put two jumper wires in those crocodile wires other heads and I connect one of the jumper wires to the negative pin section on a breadboard and the other wire to ( pin 2 ) on Arduino.
secondly,
I started to make the circuit code blocks which was:
if the ultrasonic sensor was <,= 50 cm and pushbutton = low so set the DC motor pin 5 to 180°, and pin 4 to low,3 to high that responsible for the motor direction and set the led pin 8 to high and wait 1 sec. but else set all of those to low and the pin 5 to 0°.
( and that means that the push button is the input that controls if the ultrasonic, motor, and LED will take an output action or not ).
thirdly,
I took the circuit text code from TINKERCAD then I imported it to the Arduino software and make a little modification to it which is to write pullup beside pushbutton input to make an effect.
fourthly,
I started to build the real circuit on a breadboard and Arduino Uno doing the same process that I did on TINKERCAD and after wiring everything I put the Arduino slice cable to it and to the laptop to import the code that I made to it and then the circuit work.
a small brief about the assignment:
is that the push button or the on/off switch is the input of the circuit ( project ) and by clicking on them they will make anything in the circuit run or stop.
the ultrasonic sensor is the input that will make the dc motor rotate and the led lights ( which are the outputs ) when someone is close to the ultrasonic sensor less than or equals 50 cm, and all of that by the permission from the push button or the on/off switch ( because I made one circuit with push-button and another with on/off switch).
the circuit that I made on TINKERCAD
the code blocks that I made
the code blocks with the text that I imported to Arduino software
the circuit on TINKERCAD video
the circuit code on Arduino software
wiring the circuit steps and pictures
on/off switch part of wiring
videos of running the real circuit with push button
the circuit with on/off switch video
Title of Media
I asked the instructor Esraa about running the circuit on TINKERCAD and she helped me to modify the circuit code because at first, it didn't work at all because I didn't set the ultrasonic block with the blocks.
I got stuck a lot when I was setting the code blocks on TINKERCAD because the push-button didn't control the sensor, LED, or the motor they were running without the pushbutton permission or didn't run at all but after a lot of tries and seeing a lot of coding videos I modify the code but at the end, the push-button on TINKERCAD didn't control the circuit because there was a trick in the tutorial videos which is to put the word pullup beside the input pin and this will give the whole control to the pushbutton.
there was another thing I stuck at which is to put an on/off switch instead of a push button but it didn't work or control anything on the circuit actually but again after I set the on/off switch pin to low and write the word pullup beside it as an input it works and the on/off switch controls the circuit.
the circuit i made at first but it didn't work at all and i was putting conditions on it to make the pushbutton in control
the other circuit i made and it didn't work too and because i set the pin which enables the motor to move to 90° on else which should be o°
the last circuit which I put the pushbutton pin to low and modify the pin that enables the motor to move to 0° instead of 90°
that when I set the on/off switch to pull up to have the control on the circuit
the skills that I have acquired this week is to have a lot of patience actually to try with the circuit a lot and don't give up and search a lot and a lot for codes and if I face a problem I should search about it to figure how to solve it, especially in coding.
the coolest thing that I have learned this week is coding actually, I thought before the diploma that it is something impossible to learn or even to know but after I tried I think it is still hard of course but not like I was thinking.
on the hands-on activity, the task was to make coding blocks with the buzzer and slide switch which will give you a theme song
I also made some tutorial examples like:
controlling the LED with the potentiometer
controlling the buzzer with a microwave sensor
controlling the buzzer with PIR sensor
we also had last week task my teammate was the instructor Esraa we were had to make a moving hand with the servo motor one moved in a manual way by rolling the potentiometer to move it and the other one moves in an automatic way by using an ultrasonic sensor that makes it move when someone close to it.
so we started by making the circuit first and coding it on tinkercad which will never be done without Esraa and then we started to make it on the real circuit and after that, we started to make the hands and enclosure for the circuit together.
the first task of the week was coding a theme song using buzzer
the hands on activity theme song
the exercise that controls the led brightness with the potentiometer
the exercise that controls the led to turn on /off with the potentiometer
the exercise that controls the buzzer to buzz or not with the microwave sensor when something close to it it buzz
the exercise that controls the buzzer to buzz or not with the PIR sensor when someone close to it it buzz
last week task that we made