This week was to learn the Arduino and how to think about codes and create them , So for the assignment I thought of trying something related to my final project as a part of the project was to move the shading device (Wooden strips) with a servo motor according to the sun direction . so I chose to make the input with an (LDR ) and the output from the servomotor
software used : Tinker cad
To create circuits and simulate it before making it physically
Arduino
On tinker ad
Servo+ photoresistor
The required is to make the servomotor rotate as the light intensity increases (Moving servo with Photoresistor )
Firstly I started to connect the photoresistor to the arduino :
-Terminal 2 to pin A0 to be an input for the servomotor
-And terminal 1 to the 3.3v and Ground with a resistor to prevent it's damage
-Then I connected the servomotor with the 5v, ground and with pin 10 , to be an output
Coding
To start coding I started to think for the following :
Moving servo with Photoresistor
-Input : Read analog A0 (Photoresistor )
-Output : Pin 10 (Servomotor )
-Coding tools :
.Print serial or the photoresistor (A0) to determine it's range which was from 0 to 500
. Mapping (To make the servo rotate according to the values from A0 ) , and the scale of mapping to be from 0-->180
-First block was reading A0 to read the photoresistor , then mapping it to scale it's range to be within the angles of the servo motor
-Then those two blocks are inserted in (Rotate servo motor on ) to make it rotate with these values .
DC motor +Photo resistor
Controlling the DC motor speed according to the light :
Th photoresistor was connected the same as the previous device
Dc motor one side connected to the Ground and terminal 2 is connected to the digital pin 10 to act as an output
Coding
Statement : when the photoresistor is more than 250 then the DC motor speed increases to 255 and when it's less than 250 the DC motor slows down to 20
Input : Photoresistor (A0 )
output : DC motor (Digital pin 10 )
Tools : -If condition
-First thing was to read the A0 to read the photoresistor
-Then IF condition : If the A0 is more than 250 then Pin 10 (DC motor ) reads 255 (Speed increases , Else : Pin 10 (Dc ) Reads 20 (Motor slows down
Servo +Photoresistor physically
After finishing the simulation on tinker ad ,
-I started to make the same connections physical using a breadboard
-Then I opened Arduino program , and copied the text code to it then uploaded it on the Arduino which is already connected to the servomotor and photoresistor .
DC motor +Photoresistor physically
After finishing the simulation on tinker ad ,
-I started to make the same connections physical using a breadboard
-Then I opened Arduino program , and copied the text code to it then uploaded it on the Arduino which is already connected to the servomotor and photoresistor .
-Yes I had a feedback in the midweek session , and asked about the problems I had during the midweek exercise
I had problems in understanding the coding tools and how to think about the code , I asked the instructor and had a good feedback about the sequence that I should think about when making a code , sequence : statement ,Tools , coding tools , Electronics .
At this week , I learned More about Arduino , and in the exercise I tried to make one of the functions that I want to make in the final project , so this helped me to think of it will work