The idea of week 8 is to communicate wirelessly with a smart circuit using GIU of the mobile.
I wanted to make something that produce light and alarm using the mobile to try it with my niece.
I will use an app. called Arduino Blue Control from app store to control the LED and the light.
Arduino UNO
which reads a signal from the (sensor).
I used the LED, resistor, servo-motor, bread board and wires.
Arduino app.
The Arduino UNO Connection
The 5 Volts with a positive N in the bread-board
The ground with the negative N in the bread-board
The Sensor Connections
The Bluetooth Sensor
VCC to the positive on the bread-board
Ground to negative N in bread-board
TXD to RXD of the Arduino.
RXD to TXD of the Arduino.
Note: The resistors connected to the RX pins are to convert 5v to 3.3VDC. As RX pin works on 3 Volts .
LED
The positive leg to 9 on Arduino
The negative leg to resistor to the negative N on bread-board
Buzzer
The orange wire will be connected to 8 on Arduino
the red to the positive on bread-board
while the brown is to the negative on bread-board
( I used Chat-GPT for the code)
For searching in Chat-GPT (Prompt):
I wrote: as an Arduino expert write a code for an Arduino that turn on a buzzer and a LED.
First we have to define Character:
char cache;
String inputString="";
Then Void:
We have to choose the output pins(pin 8 and pin 9)
void setup()
{
Serial.begin(9600);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
}
Finally Void Loop:
We have to tell if we press1, so make a voice and turn on LED
If we press 2, make no voice or illumination
choose if condition for 1
else if condition for 2
void loop()
{
if(Serial.available())
{
while(Serial.available())
{
char inChar = (char)Serial.read();
inputString += inChar;
}
Serial.println(inputString);
while (Serial.available()>0)
{
cache = Serial.read();
}
if(inputString == "1")
{
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
}
else if(inputString == "2")
{
digitalWrite(9,LOW);
digitalWrite(8,LOW);
}
inputString = "";
}
}
Then I tested the code on Arduino app.
How I tweaked the code?
Chat-GPT gave me the code but I had to make some debugging
I closed some brackets and curly brackets
I also put 1 and two instead of And B for the coding of the buttons we press in the mobile app.
2- Connect the Arduino to the lab-top using the USP cable.
3- Be sure you chose the right USB of Arduino and press upload.
The Arduino UNO Connection
The 5 Volts with a positive N in the bread-board
The ground with the negative N in the bread-board
The Sensor Connections
The Bluetooth Sensor
VCC to the positive on the bread-board
Ground to negative N in bread-board
TXD to RXD of the Arduino.
RXD to TXD of the Arduino.
Note: The resistors connected to the RX pins are to convert 5v to 3.3VDC. As RX pin works on 3 Volts .
LED
The positive leg to 9 on Arduino
The negative leg to resistor to the negative N on bread-board
Buzzer
The orange wire will be connected to 8 on Arduino
the red to the positive on bread-board
while the brown is to the negative on bread-board
First, I used an Arduino Uno board to control the circuit.(brain)
I used the app to control the buzzer.(Input1)
and a light sensor so if we are at night it will turn on a specific lamp. (Input 2)
( I used Chat-GPT for the code)
For searching in Chat-GPT
I wrote: as an Arduino expert write a code for an Arduino that turn on a buzzer and a LED.
then I tested the code on Arduino app.
When I press A it is not working it is only working using 1 and 2 but terminal is not preferred to kids.
so I changed the code when I press "A" LED and buzzer will turn on
while "B" will turn off them.
I kept the same led and buzzer and connections for the final project😉
I liked using mobile to control LED and buzzer.
We spent an awesome time me and Lilya🦩
We eat together, tried Karuk tea and enjoyed some different music and songs.