The assignment idea for this week is to build and Program a smart circuit using an Arduino UNO which reads a signal from an input component (Sensor, Switch, or variable resistor) to control an action component (Motor, Buzzer, LED...etc) using Code Blocks
I chose to design a music box with dancing ballerina and making a music beside with light in the background.
I got inspired from an image in image in Google search
Software app
Arduino IDE for flashing the code onto the Arduino board.
I used Cura app to set the parameters for the Ballerina model
I used the tinkercad as a simulation program that used for simulating the electric circuits.
Also I used it for writing my codes using "Co-Blocks"
Material I used.
Electric components which I used to build my circuit
CrocoCrocodile wires to join the component with Arduino/breadboard.
Red led for light
Buzzer for genarating music
Push button for turn on /off the circuit
Breadboard
Resistor to protect led to get burn
Wires (mole-male)
DC Motor
Adapter 9V to get the DC motor work
H Bridge
Other Materials which I used in crafting
Cardboard
Plastic box
Glue gun
Filament PLA
Stikers for decorations
In this project, I used three outputs (light) in Red Led , (move) in the DC motor and the Buzzer for (Sound) .
Get the power supply (9v) as the power source, I used the Breadboard to to join the circuit in ,also I used the h-bridge to control the speed of the DC motor.
I used the push button (Input) to turn on/off the circuit.
I chose the red led as the second output.
I used a resistor 220 Ohm for the led.
6.I used the Arduino for attach all the wires of the circuits ,coding and programming hardware components need an intermediate tool to adjust and to operate the code on the electronic circuits. Arduino IDE is doing this function.
Why I use 9V adapter :
because
The voltage across the motor should be around 3-9 volts and the Arduino can't give the DC motor the suitable power that it need.
Tinkercad prosses
I used Tinkercad to simulate my circuits on it and make sure that everything is working
The component I used in Tinkercad
Please note that I used IC L293D in TinkerCad instead of H-bridge as the TinkerCad doesn't have H-Bridge component.
Simulates the electrical circuit on a breadboard and Arduino.
Software design process
open TinkerCad online app and drag all needed components.
Starting with ground wire from all components (Resistor, Buzzer, Push button, Power supply, DC Motor and LED).
Unifying the ground by taking a black wire from all components and connect it with the board then from the board to the GND in Arduino Uno.
connecting DC motor and the power supply (9V) with IC L293D instead of H-Bridge as TinkerCad doesn't consist of H-Bridge .
connected DC motor to the Arduino in Analog 9 to control the speed of the motor.
connected the Led with Arduino Uno through the breadboard by analog link, also I used resistors 220 ohm to keep the LED safe
I connected a push button and buzzer with Arduino through the breadboard .
Co-Blocks in Tinkercad
Software implementation process
Tinkercad coding
Open blocks in Tinkercad and starting to write the code.
Picking an If then else condition from the control category.
Drag (return true if one of the inputs at least is true).
I need to insert one input and anyone of these inputs is true the out puts (DC motor, buzzer and Led) should work.
Set the output by dragging Set pen High or low.
Set pin 5 for the buzzer and set different tones to add "Happy Birthday" tone.
Set pin 7,8,9 for the DC motor.
Set pin 3 for the LED to high.
Finally, Set the else condition where if non of the previous input is true ==> Shut all system outputs.
After I finished coding in Tinkercad I copy the code and paste it in Arduino IDE app .
Then I changed the pinmode 4 to INPUT_PULLUP to enable the push button to work.
First I connected the breadboard with positive and nigative from arduino
I connected the DC motor with the H-Bridge
Set pin 5 for the buzzer and set different tones to add "Happy Birthday" tone.
Set pin 7,8,9 for the DC motor.
Set pin 3 for the LED .
Set pin 4 for the bush button .
Hard ware implementation process
Check all wires and components are connected properly, to the board.
check the connection between Arduino Uno and the board by following TinkerCad simulation.
connect the Arduino Uno with USB cable which connected to the lab.
Upload the code and test the prototype .
Check the problems if one of the components does not work.
Then I designed my music box to add my circuits
Final product
The challenge I faced in this project was that the push button didn't work in the bigging then I asked the instructor she told me after I send it to Arduino IDE software I should add to my input "PULLUP" to make it work properly.
It will help me in my final project in writing codes co-blocks
also will help me to make a circuit with more than one outputs
I was fascinated to write the code for count down 7 segment components and the wavy hand design at the end of week.