It's a random idea that I did for fun.
When I press 1 on the application the RGB led switch color of red, green and blue 3 times in a row with a delay 0.5 second between each color.
Number 3 starts the buzzer and 4 stops the buzzer.
I was so excited to make the first project ever that could be controlled by a mobile app.
I used Tinkercad to simulate the electronic circuit before making it in reality to make sure it's working and prevent burning of any component.
It didn't work the first few times due some errors but eventually I fixed them and it worked at the end.
I joined the RGB led with 3 resistors (one for each color) and the ground on the second leg.
the other leg of the resistors I joined them to the digital pins on Arduino; 3 for red, 4 for green and 5 for blue.
The buzzer's positive leg is joined to digital pin 9 on Arduino and the negative leg to the ground on the breadboard.
Code:
char incomingData = '0';
#define red 3
#define green 4
#define blue 5
#define buzzer 9
void setup()
{
Serial.begin(9600);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(9, OUTPUT);
}
void loop()
{
while (Serial.available() == 0);
incomingData = Serial.read();
if (incomingData == '1')
{
for (int i = 0; i < 3; i++)
{
digitalWrite(red, HIGH);
delay(500);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
delay(500);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
delay(500);
digitalWrite(blue, LOW);
}
}
if (incomingData == '3')
{
digitalWrite(buzzer, HIGH);
}
else if (incomingData == '4')
{
digitalWrite(buzzer, LOW);
}
else
{
Serial.println("enter a number from 1 to 4");
}
}
I did the exact same connection in reality as Tinkercad, I used jumpers for the wires.
I used the 5V adaptor for the power supply instead of the laptop.
I connected the Bluetooth module to send and receive data through the mobile app.
I asked for feedback about the project as it wasn't working at the beginning, as the Arduino program didn't want to upload the code.
Also at the lab we all faced problems from the robotic arm so we asked for feedback from the instructors and each others.
After the Arduino didn't want to upload the code, I asked my friends in the diploma and the instructors, and after some trial and error it seems to be that the Arduino needs to be reprogramed so I used my personal Arduino until I get to the lab and change this one.
At the beginning I wanted to implement a servo motor instead of the RGB led but it didn't work as I wanted to; I gave it the order to rotate to 90 degrees when I press 1 and return to 0 when I press 2, the problem is every time it rotates it has to stop in between and make this noisy sound, the solution for this was that I have to help the servo's shaft to rotate every single time which was not practical, so I changed the idea and came up with the RGB led idea until I get to the lab and change my servo motor.
All that not mentioning the code error which is either me typing the code wrong then fix it, or the code uploads properly but make things that I didn't have in mind.
Title of Media
It's going to give me the opportunity to use the mobile app as an input for the user (which is easier) instead of using buttons
I faced a lot of errors this week so I got more experience dealing with electronic components so I think I will consume less time making the final project with less error (isa).
Using the mobile app to control the project ,and using the power supply to power the Arduino instead of the laptop which gave me the feeling of freedom :-)
Title of Media
This is the Arduino program file:
https://drive.google.com/file/d/1GmahjWfjvJ0JSL99rdiK99ix2F69sxxg/view?usp=sharing