Final project done!
The assignment for this week is to build a simple smart circuit that contains at least 2 action components that can be controlled wirelessly. Either the Android GUI or the PC GUI should be used to control the action components.
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 replaced the sensors input with a bluetooth module:
Azouz runs when user gets closer
Action: DC motor
Sensing: Bluetooth module
User Input: via mobile app
Azouz emits sounds while running
Action: buzzer
Sensing: Bluetooth module
User Input: via mobile app
Azouz obstacles avoidance
Action: DC motor changes direction
Sensing: Bluetooth module
User Input: via mobile app
To do the merge between the three features, I will create a circuit with the bluetooth module (input), DC motor (action), and buzzer (action).
Softwares
I used Fritzing App because the bluetooth module component is not available on Tinkercad.
Arduino Bluecontrol app
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
Bluetooth module (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 PROTOTYPING the wiring of the components, I used Fritzing because the bluetooth module is not available on 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 bluetooth module, by wiring the TX in the bluetooth module to the RX in the Arduino, and the RX in the bluetooth module to the TX in the Arduino.
The bluetooth VCC node is connected to the positive row in the breadboard, and the GND node is connected to the negative row in the breadboard, so the bluetooth module is powered with 5v from the 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 picture. Mind that the two blue wires going from the motor driver to the Arduino are the digital readings concerned with operating the motor, and the purple wire is connected to the Arduino analogue pin (9) concerned with speed.
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.
FOR THE CODE
First I created char read = 0
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, the first two lines are concerned with the bluetooth module, and they indicate continous readings from the bluetooth module.
Following this, the if conditions indicate the following:
if the bluetooth reads 1: 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.
if the bluetooth reads 2: pin 7 will give out LOW and pin 8 will give out HIGH which will change the direction of the motor, and pin 6 will give out LOW which will shut down the buzzer.
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 bluetooth module, by wiring the TX in the bluetooth module to the RX in the Arduino, and the RX in the bluetooth module to the TX in the Arduino.
The bluetooth VCC node is connected to the positive row in the breadboard, and the GND node is connected to the negative row in the breadboard, so the bluetooth module is powered with 5v from the 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.
Here's the working circuit!
Marina, one of my colleagues, was facing a problem with controlling the bluetooth module via the voice option in the application. And since my circuit was ready at the same time (also I was already controlling the circuit from Marina's phone! Thanks Marina!), Esraa did her instructor's magic as shown in the videos below!
I couldn't simulate on Fritzing because the beta features tab was missing! Still working on that challenge.
Another problem that I faced was the comptability of my mobile with the Arduino bluecontrol app. No solutions till now, it has to be an android mobile.
The wireless circuit wasn't working on the first trial, so Esraa helped me troubleshoot it.
At first we made sure the app is giving the input we want it to give, and that corresponds to the code we had written; as shown in the video.
At the end, the problem was with how I connected the bluetooth module to the Arduino. I had connected the TX in the bluetooth module to the TX in the Arduino, and the RX in the bluetooth module to the RX in the Arduino, which shouldn't be. Refer to the circuit above for the correct wiring!