Final project done!
The assignment for this week is to create a smart circuit using Arduino UNO within a low fidelity enclosure. The circuit should contain 2 input components from a variable resistor or a sensor, and 2 action components.
The circuit has to be wired and simulated on Tinkercad, with Arduino being programmed using Arduino CC text.
Because I am relatively new to coding, and especially new to electronics and Arduino, I have decided to practice during the weeks on my final projects' circuits. This would leave room for me to elevate the outcome of the final project.
For this week, I added another two features of the Azouz RC car to the one created in the previous week:
Azouz RC car runs when user gets closer
Action: DC motor
Sensing: Infrared sensor
User Input: gets close to Azouz
Azouz RC car emits sounds while running
Action: buzzer
Sensing: DC motor
User Input: None
Azouz RC car obstacles avoidance
Action: DC motor changes direction
Sensing: Ultrasonic sensor
User Input: None
To do the merge between the three features, I will create a circuit with an IR sesnor (input), Ultrasonic sensor (input), DC motor (action), and buzzer (action).
Softwares
I used Tinercad to prototype and simulate the wiring, then to code the Arduino UNO using code blocks.
I used Arduino IDE software to copy the. Arduino CC text from the code blocks, troubleshoot it, then upload it to the Arduino UNO.
Electronic components:
Arduino UNO, the brain of the smart circuit
IR sesnor (input)
Ultrasonic sensor (input)
Buzzer (action)
Breadboard to wire the circuit on
Motor driver to provide the DC motor with sufficient voltage
DC motor
Screwdriver
Jumper wires
Terminal
9V power supply
For the enclosure:
Currogated cardboard
Gluegun
Cutter
Masking tape
FOR PROTOTYPING the wiring of the components, I used Tinkercad.
First, I prepared all the components.
Then I wired the Arduino to the breadboard, by wiring the 5V pin in the Arduino to the positive row in the breadboard and the GND pin in the Arduino to the negative row in the breadboard.
Then I started with wiring the PIR sensor, which I used only on Tinkercad because there's no IR sensor there. The left node of the PIR (signal) is wired to the pin 12 in Arduino, then the middle node (power) to the positive row in the breadboard and the right node (ground) to the negative row in the breadboard. Now, the PIR is operating with 5V from the Arduino, and sending signal to the digital pin 12 on Arduino.
On the other hand, the motor needs 9V, which the Arduino is not able to give. This is why I used L293D motor driver and wired it as illustrated in the pictures.
Following this, I connected the buzzer; by connecting the positive node to the positive row on the breadboard, and the negative node to the negative row on the breadboard using jumper wires.
Then I connected the ultrasonic sensor as illustrated in the picture below, making sure that it is connected to analogue and digital Arduino pins as needed.
FOR THE CODE, I built on the Arduino CC text from week 06.
First an int named PIR is created and given the value 0.
Then I inserted the ultrasonic identification line (2nd line) which I extracted from a code online.
The following block tackles the ultrasonic sensor, and is also extracted from the same online code.
In the void setup, each pin's function is specified, given that: pin 12 reads input from the PIR, pin 7-8-9 give output to the motor, and pin 6 gives output to the buzzer.
Then I typed the serial.begin(9600)
In the void l loop, I added the if condition related to the ultrasonic sensor, also extracted from the online code.
Then, the code indicates that if the PIR sesnor gives LOW: pin 7 will give out HIGH and pin 8 will give out LOW; both together will operate the motor, along with pin 9 that will give out 180 as motor speed. Pin 6 will also give out HIGH which will operate the buzzer.
Else (the ultrasonic gives a different value than than indicated in its if function; meaning an obstacle detected), pin 7 will give out LOW and pin 8 will give out HIGH which will change the direction of the motor.
First, I prepared all the physical components.
Then I wired the Arduino to the breadboard, by wiring the 5V pin in the Arduino to the positive row in the breadboard and the GND pin in the Arduino to the negative row in the breadboard.
Then I started with wiring the IR sensor, the left node of the IR (OUT) is wired to the pin 12 in Arduino, then the left node (VCC) to the positive row in the breadboard and the middle node (GND) to the negative row in the breadboard. Now, the IR is operating with 5V from the Arduino, and sending signal to the digital pin 12 on Arduino.
On the other hand, the motor needs 9V, which the Arduino is not able to give. This is why I used L298N motor driver and wired it exactly as illustrated in the pictures.
Following this, I connected the buzzer; by connecting the positive node to the positive row on the breadboard, and the negative node to the negative row on the breadboard using jumper wires.
Then I connected the ultrasonic sensor as illustrated in the picture, making sure that Trig is connected to analogue pin 5 and Echo is connected to digital pin 5.
Here's the working circuit!
Now, creating the enclosure...
Then, I placed the components inside; each in its respective spot. And here is the full thing tested!
At first, I chose a different ultrasonic sensor than the one I have, then my instructor gave me heads up.
For some reason, the motor driver becomes corrupt when simulating, although its connections are the same as the circuit in week 06. I'm still looking into this.
Another challenge I also faced was the size of the breadboard when it came to creating the enclosure. I haven't considered the size of the breadboard before designing the enclosure, and thus I had to move the wiring to the mini breadboard later on.