Color toy
This week we were assigned to Communicate wirelessly with a Smart Circuit via a Graphical User Interface (GUI) on our phone or PC.
I thought about prototyping a kids toy which van change color and display the color name via serial monitor . it also has different animal sounds.
Software:
Fritzing to draw the circuit wiring.
Arduino IDE to write and upload the code .
Materials:
Arduino UNO.
HC-05 Bluetooth Module.
Piezo Buzzer.
Breadboard.
Jumper wires.
220Ω Resistor.
RGB LED
-
HC-05 Bluetooth module
Arduino UNO
-
Buzzer
it's a pretty straight forward process .
You can check the Bluetooth module Pinout here :
as You can see in the attached circuit, you leave out the enable and state pins for this excersie, you wire your power normally, and then you connect the TX pin to Arduino's RX pin and vice versa.
Circuit on fritzing
Started by designating a positive rail and a ground Rail on the Breadboard.
connected a 220 Ω resistor on each of the R G B LED pins.
connected the Bluetooth module on the TX and RX pins. per the pin-out diagram share earlier.👆
wrote a program to check the incoming data over Bluetooth from the app and to change the RGB Values based on that data.
Circuit
#define red 9
#define green 10
#define blue 11
#define buzzer 12
char incomingData = '0';
void setup() {
Serial.begin(9600);
pinMode(buzzer, OUTPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop() {
// don't display data on serial monitor if there is no change.
if (Serial.available() > 0)
{
incomingData = Serial.read();
}
// change colors to red if received order 1
if (incomingData == '1') {
analogWrite(9, 255); //red color
analogWrite(10, 0);
analogWrite(11, 0);
delay(1000);
Serial.println (incomingData);
Serial.println ("Color RED");
}
// change colors to green if received order 2
else if (incomingData == '2') {
analogWrite(9, 0); //Green Color
analogWrite(10, 102);
analogWrite(11, 0);
delay(1000);
Serial.println (incomingData);
Serial.println ("Color Green");
}
// change colors to blueif received order 3
else if (incomingData == '3') {
analogWrite(9, 0); //blue color
analogWrite(10, 0);
analogWrite(11, 153);
delay(1000);
Serial.println (incomingData);
Serial.println ("Color BLUE");
}
// change colors to white if received order 4
else if (incomingData == '4') {
analogWrite(9, 255); //White color
analogWrite(10, 255);
analogWrite(11, 255);
delay(1000);
Serial.println (incomingData);
Serial.println ("Color White");
}
// play buzzer if received 5
else if (incomingData == '5') {
tone(buzzer, 20, 200); //Play tune 200HZ
delay(150);
noTone(buzzer);
delay(200);
Serial.println (incomingData);
Serial.println ("Cricket SOUND");
}
else if (incomingData == '6') {
noTone(buzzer);
delay(1000);
Serial.println (incomingData);
Serial.println ("Buzzer OFF");
}
}
Arduino UNO
An Important tip that was shared is that you need to detach the Bluetooth module read and write pins to be able to upload any code through the IDE, since the serial port are internally wired to those pins as well. it saved us some time scratching our heads on why we're not able to upload any code : )
whenever we got stuck, thee first option is always to search for an answer online. if you're lost ask your supervisors to direct you on where to search.
Google is your best friend
PLAN!
Getting through a project from scratch was interesting to do. surly will help with planing our final project.
It was interesting learning about how PCBs are made
Pcbs explained
It was Fun working on a robotic arm this week.
robotic arm