Design and program a smart device that perform a certain function or solve a problem: program Arduino UNO to read signals from multiple input components (Sensor, Switch, or variable resistor) to control multiple action components (Motor, Buzzer, LED...etc) using Arduino C (Text Code).
Interactive lamp
Interactive light, when it senses movement it flashes. It can be controlled using a switch.
It has a screen that displays the mode you are in.
Tinkercad to design the circuit
Arduino to upload the code
9V adaptor
Arduino uno and usb
Jumper Wire
LCD
Bluetooth module
RGB LED
Resistors
STEP 1
I designed my circuit on Tinkercad.
I used the LCD & RGB LED as the output component and the Ultrasonic module and switch as the input component.
I used 9V adapter as a power source.
I used Arduino Uno as a controller.
I simulate the circuit on Tinkercad.
The goal of the project is that when it senses movement it flashes. It can be controlled using a switch. It has a screen that displays the mode you are in.
STEP 2
I start by searching for codes.
After researching how to write the special components in the project, I started writing the code that achieves the project goal.
I started by defining the LCD library and defining each pin of the LED.
void setup() In this void we will define INPUT and OTPUT. I also specified the word that will be displayed initially once when the circuit is connected.
void loop() At this void, we will set the scenario that the process will follow.
When I move the switch to the outside of the smart mode, the reading received by the sensor is read, and if it is less than 50 cm, the flashing mode is activated.
When it does not sense movement, it lights up white. the screen says “smart mode.”
the screen says “Celebration Lights.”
When you move the switch to the manual position, the lamp flashes, and the screen says “manual mode.”
In the end, I checked the code, then connected the Arduino, selected the board, and uploaded the code.
STEP 1
I made my circuit.
I connected the LED to the coded pins and connected a resistor to each pin.
After that, I connected the screen so that the VCC pin is with the 5 volts, the GND pin is with the GND pin for Arduin, the SDA pin is with A4, and the SCL pin is with A5.
After that, I connected the ultrasonic sensor by connecting the VCC pin to the 5V, the GND pin to the Arduino pin, and the Trig and Echo pins to two digital pins NO.2,3.
After that, I connected the switch slider one of the pins is on the ground, the second is on 5V, and the third is on the digital pin.
connect the 9V adapter and test the circuit.
When I uploaded the code, I found that it did not work, and the error was in connecting and defining the slider switch.
I searched for how to connect it and found that it is connected as follows: one of the pins is on the ground, the second is on 5V, and the third is on the digital pin.
I understood how I start coding on Arduino software and write my code.