THE IDEA for this week the assignment was to code and develop a smart device using arduino uno and tinker cad code blocks and implement the circuit in real life.
The inspiration i have decided to make a trial run for the final project and control a servo motor using the analog read of an LDR sensor. this circute can serve as a proof of concept for the final project. later the servo can be replaced with a stepper motor to make the movement smoother and more rigid .
below are the tools and softwares i used to finalize the assignment:
tinkercad for coding and simulation
arduino IDE for flashing the code onto the arduino board
breadboard
jumper wires
power supply terminal connector
brain, input and output components
LDR sensor module (input component)
Arduino Uno R3 (Brain)
micro servo motor (output component)
testing the LDR Coding
1 - i started by researching how to code arduino using tinkercad code blocks to receive an Analog output with arduino.
2- since tinker cad didn't have an LDR sensor module i researched how i can compensate for that and found a circuit that implements a photo resistor to serve as a sensor module.
3- this circuit has the same concept of reading the analog input from a POT on pin A0
testing the LDR Coding
4- to make sure my wiring was correct and to get a better understanding on how it works and what the analog input of the LDR looks like i used serial monitor to view the reading of the LDR
reads the analog input of the LDR on PIN A0 and prints the value in a new line in the serial monitor - waits 1 second before reading and printing the new line
5 - serial monitor reads the input - proof the circuit is correct
6- add the servo motor to the circuit
circuit wiring diagram showing the H bridge connection and the lamp on off switch
7- after connceting the servo it is time to code the smart device. since the normal method of mapping the value of the LDR reading on the servo degrees will result in aggressive and sudden movements i decided to go with a more dynamic method
8- creats a variable called (LDR_servo) to store the the servo angel according to the LDR reading
9- creates a variable called (set_servo) to store the current servo angle
8- the below block reads the analog input on pin A0 and maps the input from 1023 to 180 degrees of the servo and stores that value on the variable (LDR_servo) [now the value stored in the variable is the angle we want the servo to go to )
9- the below block reads the current degree of the servo attached on pen 3 and stores it on the variable (set_servo)
10- the below block increases the value of (set_servo) by 1 degree if the value of (set_servo) is less than the required value for the servo by the LDR stored in (LDR_servo)
11- then sets the rotation of the servo to the value of (set_servo) [this will loop until the value of (set_servo) = the value of (LDR_servo) ]
12- the below block decreases the value of (set_servo) by 1 degree if the value of (set_servo) is bigger than the required value for the servo by the LDR stored in (LDR_servo)
13- then sets the rotation of the servo to the value of (set_servo) [this will loop until the value of (set_servo) = the value of (LDR_servo) ]
14- waits for 0.5 seconds before running the loop again
15- prints the value of the variables into the serial monitor for testing and visualizing the effect
final running code
14- implement the diagram in real life and test the the LDR and servo on the breadboard
15- to flash the code onto the arduino i used arduino IDE
16- copy the code text from tinker cad
17 - after opening arduino IDE, delete the existing code
18 - paste the code from tinker cad to the IDE
19 - before flashing the code make sure that i have selected the correct board and port in the arduino IDE
20 - verify the code in IDE ( no errors)
21- upload the code to the arduino
making sure i selected the correct board and port
making sure my code has no errors (verifying my code)
the first challenge was to find the LDR sensor module on tinker cad
after research i found out that there was no LDR sensor module but there was a photo resistor
i researched hot to use a normal LDR to work as an LDR sensor module and i found the below example
4- after drawing the schematic on tinker cad i coded the arduino to print the value of the analog input pin A0 to view the changes in real time as a testing technique for the new schematic
5- i found that it was working and the schematic worked as intended in real life with and arduino
i chose this prototype since it is essentially a part from my final project coded and wired with arduino using a servo motor instead of a stepper motor. when i succeded and i got the output i wanted, now i have proof of concept that it can work and i have a better understanding of how the LDR works and what kind of limitations it has. now i can focus more on the other sections of my final project.
this week we had the make diploma W23 dish party and it was an amazing time
participated in creating the longest tower with sticks and connectors - over 2.5 meter tall
partecipated in the organization of the dish party and design and fabrication of the giveaway . it was amazing to work with Rabie on a colaboration of leather and wood
had many fun activities
Week Wrap Up In Pictures