My assignment's idea for this week is very close to that of week 7 but interacting wirelessly via a bluetooth module to the PC. As I wanted to comprehend this skill through incorporating it in my final interactive projector project, but I knew it might be too much for the time limit, so I wanted to do it in week 8.
I wanted to add another output, besides the led to try and since the assignment requires that anyway., so I added the Piezo buzzer.
1-Software :
TinkerCad
Arduino Coding
Processing
2-Tools& materials:
Arduino UNO
Bluetooth Module
RGB LED
(3) 220 ohm Resistor
Buzzer
breadboard
Jumpers
USB Cable
First, I planned my circuit on tinkercad:
First, I picked the components, and I used an old shared file on the internet that had the bluetooth module and I tinkered and edited it.
I connected the rgb led to the resistors.
I connected the RGB led's end to digital pin R, G, & B to 8, 10 & 9 respectively and the resisters to the ground.
I connected the Bluetooth module (RX - TX - GND - VCC ) to ( TX (1) - RX (0) - 5V - GND ) on the arduino respectively.
I added the buzzer to digital pin 2.
2 . Then, I worked on my code on arduino :
I defined my components and their pins using the # define function.
I added the bluetooth related coding setup ( Char Incoming data ).
In my ( Void Setup) section: I defined the (rgb led & buzzer) as my 2 OUTPUTS, and digital wrote them as low. Also, I initiated the serial function.
In my (Void Loop) section: I started to design the program according to the buttons. First, it's important to understand that we have 4 buttons which translate to incoming datas:
1st button ( Low - High ) = ( 0, 1 )
2nd button ( Low - High ) = ( 2, 3 )
3rd button ( Low - High ) = ( 4, 5 )
4th button ( Low - High ) = ( 6, 7 )
I added the condition while serial available equal zero, the incoming data will be read from the serial.
I then added an If condition ( using incoming char == 'value' function ) ( with my program's functions), stating that :
if button 1 is low / incoming data is 0 = digitalwrite the rgb and the buzzer as low as well.
if button 1 is High / incoming data is 1 = digitalwrite the rgb RED as high and the buzzer as high as well.
if button 2 is low / incoming data is 2 = digitalwrite the rgb and the buzzer as low as well.
if button 2 is High / incoming data is 3 = digitalwrite the rgb GREEN as high and the buzzer as high as well.
if button 3 is low / incoming data is 4 = digitalwrite the rgb and the buzzer as low as well.
if button 3 is High / incoming data is 5 = digitalwrite the rgb BLUE as high and the buzzer as high as well.
3. I tested my connection on the arduino:
First, I connected the jumpers to the breadboard following exactly what I did on the tinkercad.
I connected the USB to the arduino, and I uploaded the code to it.
I downloaded the processing and I added the bluetooth module name
I tried testing it and pressed the butoons and it did do what I programmed.
I had trouble connecting the processing code to my bluetooth module as it didn't have the names provided in the video but I found that the windows differ from the mac. Rawan had asked this qyestion on the slack. Thank you Samir for the answer !!
I also at first didn't understand how to use the bluetooth module in the tinkerCad, I found that Manar had asked that question on the troubleshooting channel.. Thank you esraa for the answer :")
The bluetooth module.
Controlling my components wirelessly.
The robot arm design.