Week #8 - Journal
kinetic facade proof of concept and preliminary prototype - environment sensor & controle panel &wirles communication via Bluetooth HC_05.
Tell us about your assignment's idea for this week. Why do you care about this idea? What inspired you? (Please include images or links to sources of inspiration)
THE IDEA for this week the assignment was to code and develop a smart device using arduino uno and a bluetooth module and implement the circuit in real life.
for the assignment i decided to build on the assignment of week 6&7 and implement more components from my final project.
The inspiration this week is an integration of different parts from my final project as a proof of concept. i decided to integrate the assignment of week 6 & 7 and add wireless communication via Bluetooth to read data from the sensors and control movements.
Tool Chain
Which software/machines/materials did you use in the assignment? Why?
below are the materials i used for the cardboard model of the assignment:
toung depressor
cardboard
below are the tools and softwares i used to finalize the assignment:
tinkercad for circuit diagram
bluetooth terminal android app - for serial communication via wireless bluetooth module HC-05
arduino IDE for coding and 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)
DHT11 temperature & humidity sensor module (input component)
16x2 liquid crystal display with I2C interface (output component)
push button (input component)
on/off switch
5v power adapter
Potentiometer 1Kohm (input component)
on/off switch
5v power adapter
Potentiometer 1Kohm (input component)
Week #8 addition
HC-05 bluetooth module as input and output component (wireless communication)
Design Process for environment sensor & controle panel
Explain the design and/or preparation process of your assignment. How did you use the tool or software to design and/or prepare your assignment before fabrication/implementation?
1-now i have experience with each component individually i is time to finalize the circuit on a breadboard and the diagram
2- add all the input and output components
3- after connceting the components it is time to code the smart device.
4- add the libraries required
5- adds the libraries required to controle the LCD and defines the I2C address of the LCD
6- includes the servo library and defines servo pin as pin 3
7- includes the DHT11 library and defines that the DHT11 is connected on pin 6
8- defins the button attached on pin 2
9- creates a variable (mode) to store the mode of the device (1=auto mode) (-1 = manual mode)
10 - creates a variable(LDR_servo) to store the input reading we want to set the servo angle to ( from the LDR)
11- creates a variable (set_servo) to store the current angle of the servo.
creates a variable(pot_servo) to store the input reading we want to set the servo angle to from the potentiometer
creates a character variable to store the reading of the serial monitor from the Bluetooth module
12- the setup function runs once and in this case declares the following:
servo attach on pin 3
declares that pins A0 & A1 are input pins
declares pin 2 (button) as input pullup to attache a push button to the the ground of the arduino
begin the LCD screen communication
starts serial communication at 9600
13- creats the following variables
creats a variable (temp) to store the temperature data from the DHT11
creates a variable (hum) to store the humidity data from the DHT11
stores the reading of the serial monitor on the variable (BT)
14- this is the statement i used in the previous version of the code , it assumes that there is only 2 values for the variable (mode) and since to achieve the movement i want in this version of the device i need and exit status from the state auto and the state manual this value is 0 for when the shade is open and shade is closed and i want them to stay open pr closed and not enter into the auto mode or the manual mode
OLD way i stored and altered the mode of the input
15- the addition is an if condition to exit the open and close shade mode of the shade and it reads as follow:
if the variable (mode) is not equal to 1 and not equal to -1 and if i press on the mode button or send via BT serial GUI the letter A for auto or M for manual make the value of mode = 1
the new way
16- modified the mode shifter to accept the input from the Bluetooth serial communication .
if the variable (mode) is equal to 1 or Equal to -1
and if i press on the mode button or send M or A via BT serial GUI change the mode between auto and manual
17- clears the LCD screen and prints the current mode of the device on the LCD screen (i added the a new value for the mode variable = 0 which is the value of the 2 extra actions i added open shade and close shade) which is also considered as manual mode
and prints the mode on the serial monitor so i can see it on my phone via Bluetooth Communication
18- prints the current angle of the servo on the LCD on the same line as the mode
19- prints the tempreture and humidity from the sensor on the second line of the LCD screen
20- prints the same data from the LCD to the serial monitor so i can see it on my phone via Bluetooth Communication
Automatic Mode
21-if the mode is set to automatic the program executes following code
22- 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 )
23- reads the current degree of the servo attached on pen 3 and stores it on the variable (set_servo)
24 - 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) and then sets the rotation of the servo to the value of (set_servo)
25- 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) and then sets the rotation of the servo to the value of (set_servo)
26- [this will loop until the value of (set_servo) = the value of (LDR_servo) ]
Manual Mode
POT shade control
27-if the mode is set to Manual the program executes following code
28- reads the analog input on pin A1 (from the potentiometer ) and maps the input from 1023 to 180 degrees of the servo and stores that value on the variable (POT_servo) [now the value stored in the variable is the angle we want the servo to go to )
29- reads the current degree of the servo attached on pen 3 and stores it on the variable (set_servo)
30- sets the servo to the angel stored by the (pot_servo)
shade closed action
31- closes the arm shade when the value of the BT variable reads C (close)
32- changes the value of the mode variable to be 0 (prevents the loop from reentring the auto mode and reads from the LDR or entering the manual mode and reads from the POT
33- opens the arm shade when the value of the BT variable reads O (Open)
34- changes the value of the mode variable to be 0 (prevents the loop from reentring the auto mode and reads from the LDR or entering the manual mode and reads from the POT
Complete code
1
2
3
4
5
Development/Implementation Process
Explain the development/implementation process of your assignment. How did you use the machine/tool to manufacture or implement the design of your assignment?
35- implement the diagram in real life
36 - before flashing the code make sure that i have selected the correct board and port in the arduino IDE
37- before flashing the code make sure you remove the Rx and TX pins from the arduino
38 - compile the code in IDE ( no errors)
39- 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)
part preparation and assembly
Overcoming Challenges
What kinds of challenges or problems did you face while doing the assignment, tutorials, or exercises? How did you solve them? Did you ask for help from an instructor or peer? Please provide a link to the tutorial or article that you used to solve your problem (if any)
the first challenge was to creat a new state for the mode so it would stay closed or opened when i give the order through Bluetooth.
in the close and open loop i changed the value of the variable mode to 0 (this prevented the device from entering the auto mode or the manual mode again when the loop reruns)
this created another problem that i couldn't change between auto and manual mode since mode ended the loop with the value 0
after research on how to include both AND & or operators (&& || ) i found i can make either 2 operators but the order of them will be set by brackets. in this way :
the above code while correct in syntax but i contains a logical error
the code ran normally and once the mode got to manual it could not get out of the manual mode because condition of the upcoming if function will be never met to switch the mode
after 4 hours of debugging i found the logical error that i needed to modify as following which worked in both itterations
first way of assigning the conditions of if functions
second way of assigning the conditions of if functions
Final Project
How can you use the skills and knowledge that you've acquired this week in your final project?
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.
WOW!
What is the coolest thing that you've learned this week? What is something that you will never forget from this week?
extra session to make jewlery using wire frame electronics
my first test of the LCD
Weekly Digest
Tell us about any other cool things that you've made this week: in the Hands-on activity, tutorial examples, exercises, or any other cool mini-project that you tried out aside from the assignment.
Week Wrap Up In Pictures