Welcome 😊
This week we had to build and program a smart circuit using an Arduino UNO & control it using Bluetooth module.
This week our assignment is to build and program a smart circuit using an Arduino UNO & control it using Bluetooth module and programming it using Arduino C code.
My inspiration came from a smart alarm system that used to secure a house.
Fritzing used to design my circuit diagram.
Arduino IDE used to program the Arduino UNO.
Fritzing circuit
I start by using Fritzing to build my circuit diagram.
Fritzing Components that I used during designing:
Arduino UNO
LCD Screen + I2C Module
Microwave Motion Detection Sensor (RCWL-0516)
Bluetooth Module (HC-05)
Buzzer
2 Inputs: (Microwave Motion Detection Sensor & Bluetooth Module)
2 Outputs: (LCD Screen & Buzzer)
Braking Down:
I connect the LCD Screen to the Arduino by connecting VCC to 5V pin, GND to GND pin, SDA to A4 pin and SDL to A5 pin.
I connect the Microwave Motion Detection Sensor to the Arduino by connecting VCC to 5V pin, GND to GND pin and OUT to D2 pin.
I connect the Bluetooth Module to the Arduino by connecting VCC to 5V pin, GND to GND pin, TXD to D0 (RX) pin and RXD to D1 (TX) pin.
I connect the the anode terminal of the Buzzer to D11 and cathode terminal to GND pin.
AlarmSystem.ino code
I start by install and including the libraries needed for the LCD Screen, then defined the pins numbers and some variables that I'm gone need during writing my code.
Then I start by creating some functions that would make my life easy as It would reduce the line of code by write the function code once and re-use it every time I need it instead of writing it all over again when I need the same part of code.
setup() : It start by initialize communication between the Arduino and the LCD screen, then set pin mode and set the serial communication speed and print some text on the LCD Screen.
loop(): It start by while loop that as long as it's condition true it keep working until the condition is become false then read form the serial port and assign it value to a variable then a bunch of if conditions everyone of it check for specific condition and based on the condition it execute a part of code related to that condition.
I used the same components as on Fritzing I wire it all and I placed the buzzer directly on the Arduino connecting it to D11 and GND pins then I connect the Arduino to the computer and upload my code.
When powering on the Arduino the alarm is disabled then by controlling it via Bluetooth I can arm the alarm so if any movement happened in the range of the sensor it riggers the alarm and buzzer fire up until I disable it manually also I can trigger the alarm manually for testing.
Alarm System
❤️
Me and my team-mate Michael. We managed to build and program a simple robot arm using Arduino and control it using Bluetooth module during EoWeek Makeathon.
Also me and colleagues, we all like to talk and sharing knowledge & ideas.
❤️
Our robot arm in action
While I was tasting my code. When the alarm is triggered the buzzer only fire up for 1 sec and stops which it means that the loop function only run once and stop so after I do a quick rubber duck debugging I found out that the program get stuck in another infinity loop and only breaks when I send char via serial so I edit the while loop condition to only run when there is no serial available and when the alarm is disabled and it work as needed!
Before
After
The skills & knowledge I have acquired this week would help me using the Arduino in my project.
The Microwave Motion Detection Sensor (RCWL-0516) is so sensitive and had high range.
I learned how to add new components to Fritzing.