This week, the idea was inspired by the "Ramadan Lantern", which is the closest application to what will be implemented in the final project. The goal is to make an electronic unit that is sensitive to light. When the light is low, a LED and DC-Motor are turned on in parallel with the possibility of controlling the intensity of the light.
Software:
Tinkercad: To design the electrical circuit, make sure that all parts are working and simulate what will happen in reality, and make the code using blocks.
Arduino IDE: to check and upload the code to the Arduino Board.
Components:
Arduino UNO to control all the components.
USB Cable to connect Arduino Board with Laptop.
DC motor for the movement. 5 VDC - 0.65 A
L298N Driver Module to control the power and speed of DC-motor.
RED LED 1.8 VDC - 20 mA
Resistors - 220 Ohm for LED
LDR Module To sense the intensity of light and give the signal to the Arduino board
1K Potentiometer for LED intensity control
Breadboard to connect the components.
9V Power-supply
Jumper wires + Crocodile wires
Tools:
screwdriver to assemble the components.
I used the Tinkercad to design the electrical circuit and make sure that all parts are working and simulate what will happen in reality. and I used the previously mentioned components.
This process was divided into two stages.
In the first stage: I connected the potentiometer with the LED and the PIR sensor instead of the LDR module, but it will do the same function and the code can be generated using it.
Mode: off
Mode: On without using potentiometer
Mode: On while using potentiometer
This code enabled me to turn on the LED using a potentiometer only, and the LED did not turn on automatically when the sensor sensed low light.
This code is completely wrong as it gave two commands to turn the LED on. Which made it light on and off quickly and Consecutive.
In the end, I reached the correct code that makes the LED turn on at low light intensity, and then we can control it through a potentiometer.
In the second stage: I connected the Dc-motor, L293D IC, and the power supply to the previous circuit. and edited the code to run the motor also when the LDR sensor senses the low light intensity.
Note: L293D IC = L298N driver module.
Mode: off
Mode: On
Mode: On
when LDR Sensor senses high light
Then I added commands to run the motor to the previous code
I started assembling the circuit with the following steps:
I connected the positive and negative from the breadboard to the Arduino
I connected the LED to the breadboard and the resistor and make the anode of the LED connected to the digital pin number 9 to read the analog voltage.
I connected the potentiometer to the breadboard and make its middle-end connected to the Analog pin A0 to control the led light intensity
I connected the LDR Sensor module to the breadboard and make its DO Pin connected to the digital pin number 2 to sense the light intensity
I connected the DC-Motor to the L298N driver module based on the attached circuit diagram, and the module to the Arduino board using the digital pins 3,4 and 6
I uploaded the code using Arduino IDE
Test Full circuit. and finally, it works well.
Ahmed Abdel Nasser helped me choose the appropriate code to run the circuit, and pointed out several points that help me in programming in general, such as the flow chart, and this will be very useful in the work of the final project.
In this week's activity, I learned about the Ultrasonic sensor and writing its code in cooperation with Magdy. We have done more than one experiment using the Potentiometer and Ultrasonic using two servo motors.
I faced a problem when uploading the code to the Arduino board, and by searching on YouTube and the Arduino website I found the solution, I followed the steps and tried to discover the error, then I re-uploaded the code and the problem was solved.
This time I got very close to the idea of the final project, I used almost the same pieces that I will use and generated the code that is similar to what will be implemented in the final project.
I never imagined that I would write code someday, and make it a bit complicated, at least for me!