The idea of this week to use Blutooth module to control two outputs. Used LEDS to give different statues and servo.
to build and simulate my circuit before making it IRL
Arduino IDE
upload my code to my Arduino
The Arduino Bluetooth Controller Application make to able to remote control your device with Bluetooth Module and Arduino Board.
integrated into a variety of electronic projects
emits light when an electric current flows through it
Servo Motor
rotate an object with great precision
330-ohm resistors
limit current
This class 2 Bluetooth module (HC-05) comes programmed with firmware that allows it to pass the output of a serial communications port
for building temporary circuits
to wire it all up
Started by adding the components I need in my workspace and also available in my electronic kit.
Then connected each component to the breadboard and to specific pins on Arduino.
connected the Servo motor to pin 9 on Arduino.
This Arduino code controls a servo motor and two LEDs (red and green) based on serial input. It includes the Servo library and defines pin 10 for the red LED, pin 11 for the green LED, and pin 9 for the servo. In the setup() function, it initializes serial communication at 9600 baud, sets the LED pins as outputs, attaches the servo to pin 9, moves it to 90° (neutral), and turns both LEDs off. The loop() function continuously checks for incoming serial data. If '1' is received, the red LED turns on, the green LED turns off, and the servo moves to 150°. If '2' is received, the green LED turns on, the red LED turns off, and the servo moves to 170°. Any other input turns both LEDs off and resets the servo to 90°. The serial monitor provides real-time feedback on received commands and actions.
Prepare all the electric circuit components to build the circuit.
Build the circuit as designed on Tinkercad. After powering the circuit, the light are connected in arduino.
Press the button, the circuit is working perfectly.
In the final project, I need to make sure that the sensor is in the right place with right numbers
Serial.available() returns the number of bytes in the serial buffer.
If it's greater than 0, it means there is data available to read.
If we used = (e.g., if (Serial.available() = 0)), this would be a syntax error because = is an assignment operator, not a comparison operator.
i miss to put the resistor to the ground
When you are debugging the code, don't search for the error message; try to read the code like you try to identify each function and what the output of this function is. If you do this, you will find the problem and solve it. That's what I do in this problem when I think and ask why and what the difference is between = and > Here I find the answer.
Don't put the Arduino and the power source at the same time; the Arduino will burn.