Tutorials
Hands-on Flow chart
Exercise 1
This week contains 4 main milestone activities:
Midweek , EOweek Videos and tutorials include how to write Arduino C code syntax correctly. Also Creating and using Variables to store and manipulate different types of date in Arduino C. Exploring New Data Types: Char, String, and Array in the safe password tutorials.
practicing on some Exercises as making a code of LED Toggling Riddle. Also, the Password Protected Safe Project.
Doing the Weekly assignment about building and programming a smart device by managing manual / automatic modes using an Arduino UNO which reads a signal from an input component ultrasonic sensor, potentiometer, and a switch to control an action component Motor and RGB LED using Arduino C codes.
Coding Via Arduino IDE
Practising Tutorials
For the materials: i used some electrical sets from the given Kit as follows:
Along the week Assignments
Arduino Uno
Servo Motor
RGB, LED Lamps 2.2V
Slider Switch push buttons
DC Power Adapter 9 V
DC Jack to terminal block converter
Jumper Wires MM, MF
Screw Driver
Buzzer 5V
Potentiometer 1 K ohm
Resistor 220
Breadboard
USB Connection
LDR Sensor
Ultrasonic Sensor
LCD Liquid crystal IC2
KEYpad 3*4
In the Smart Device i made, I used:
Arduino Uno
Resistor 220
Servo Motor
RGB LED Lamp
Breadboard
Ultrasonic Sensor
Jumper Wires MM, MF, FF
USB Connection
Slider Switch
Ruler
Potentiometer 1 K ohm
Wires
Ruler
Card Board
Crocodile Wires
Acrylic for polishing
Glue Gun
double face
Metal Wires
ACrylic Paint
For the software:
I used the tinkercad as a simulation program that used for simulating the electric circuits.
Arduino Uno IDE 1.8.15 programming Software.
Code2 Flow online website to sketch the coding logic before the implementation.
Metal Wires
Arduino Uno
Arduino Uno IDE programming Software
Code2 Flow
KEYPAD 3x4
LCD screen
Glue Double Face
Screw driver
Card Board
Breadboard
Servo Motor
RGB LED
Resistors 220 ohm
Wires male male
Potentiometer
USB Connection From Arduino to Laptop
Ultrasonic Sensor
Mini Breadboard
Motor Driver L298N
Relay Module
Ex. 1: LED Toggling Riddle!
First, i made a sketch and a flow chart explaining the order of the required circuit.
2. Then, I began to write the code directly in Arduino IDE coding software.
3. Beginning with assigning values to an integer variables, the 4 leds and the Button i used. The 4 anodes LEDs green A- red B-yellow C-white D by sequence, I assigned them to the analog pins on the Arduino Uno 3,5,6,9 respectively.
4. Then, I began to build the void Setup () part. I defined the state of each entered pin to the code as follows. the Led pins are all as output and the button, potentiometer as an input. the button with a digital pin and the potentiometer as an analog pin A0. i Added the serial. begin(9600) to read all the values of the Arduino in each step. The push button was wrote as an INPUT-PULLUP.
5. Then, I began to build the void loop() part. i concerned about the less at first, so I began to test the code written for the 4 LEDs. i made the toggling effect but as a continuous mode. This step was to check that all things go right. So I made each LED opens by sequence with a separation of 1000 milliseconds.
5. the next step was to think about the best function to do the toggling effect on the lamp using the Push-button. So I typed the If Function of reading the digital pin of the pushbutton. if it is as low, so the toggling effect will be from right to left automatically as required. Then I print the output to see if the push button was working as 1 or 0 values.
6. Then, i made a For Function in order to repeat an order as a continuous logic loop. the Arduino will calculate with this equation if pushbutton was low/0 >>> then going to the For loop and choose the button equation with value of 0. if else >> pushbutton was high/1 >>> then going to the For loop and choose the button equation with value of 1. this will make the reverse effect with - direction. Also, I printed each button value to see the effect on my laptop screen.
7. At the end, i added the potentiometer analog equation in the beginning of the loop. and Scaling it with using the map function from 0 to 255. Also printing its serial values to check the speed of toggling on the screen.
8. then I saved the file, and upload it to the Actual Ardunio after porting it with the USB.
9. The next step was to implement it using physical components and the Arduino UNO board to build it.
Ex. 2: LCD with KEYPAD PASSWORD!
I began to write the code directly in Arduino IDE coding software.
First of all, i loaded the libraries that wil be used in this task, <Keypad.h>,<Wire.h>,<LiquidCrystal_I2C.h>, <Servo.h>.
3. Beginning with assigning values to an integer variables, I assigned the coulmns and rows of the key pad and their values . then assign each row and column to a specific pin in arduino uno. Also i assigned the lcd type LiquidCrystal_I2C(0x27, 16, 2). At last, I entered the sequence of the password cod that contains 4 digits and an enter key.
4.Then, I began to build the void Setup () part. I defined the state of each entered pin to the code as follows. i Added the serial. begin(9600) to read all the values of the Arduino in each step. the lcd codes to read all the values of the Arduino in each step.
5.Then, I began to build the void loop () part. I defined the lcd set cursor place and the entry word to enter the password. then to the set digits step , i set the counter from 1 to 4 and then # as an enter key. in each step the lcd will print the number that was added by the user and wait 500 milisc to transfer it to this char *. All are shown as follows:
6.Then, the check password step, i used the IF condition to check whether the pass was right or wrong. and along the 2 cases the lcd will print to the user the code state. if it is right (ACCESS APPROVED), and if it is wrong (ACCESS DENIED)
3- Assignment of the Smart Device using an Arduino UNO
The main idea: I have upgraded last week's circuit. I made one circuit that combines the manual and automatic complete mode of the circuit of my final project.
Main Concept: It has two modes one for manual and the other automatic mode for control. IN the manual mode, the user will modify his preferences of the louvers angle by using a potentiometer.IN the Automatic mode: It begins with taking input motion signals from the distance between the users' workflows and the wall by using ultrasonic sensors. It will differ its opening angle according to the distance of the occupants. and The wall will emit different lights according to its opening angle states. The fully Closed state 0 for detecting no one in space with a far distance of more than 40 cm / the light will be purple then- semi-opened/closed state 45 for detecting a near body from the wall between 40 and 20 cm and the color will be cyan color Fully opened state 90 for detecting a very near body less than 20 cm with green color.
Also, there will be a slider switch to modify the modes and an on/off switch to open or close the whole device.
The technical components: the ultrasonic sensor, on/off switch, potentiometer and the slider switch are as input component, the output component: motion and light, the action components are done by using servo motor and RGB LED, The brain is the Ardunio UNO, power management: the breadboard will take the power from Ardunio UNO that is taken from the laptop by using USB.
Main components I used: Ardunio UNO, on/off Switch, potentiometer, slider switch, ultrasonic sensor, Slider Switch RGB LED, and the Servo motor.
The Datasheets of each component are as follows:
Arduino Datasheet
From Datasheets>>>For RGB LED:
Required Blue color voltage= 3.2 V
Required Red color voltage= 2 V
Required Green color voltage= 3.2 V
For Servo motor:
Required voltage= 5V
Angles from 0 to 180 degrees.
For Ultrasonic sensor:
Required voltage= 5V
Current =15 mA max
Input of Arduino = 5Volt
5-3.4=40/100R
R= 230-320 Ohm ( for RGB LED resistors).
Steps of implementation on Arduino IDE
First, i begin to assign each value that will be used to integer variables, the distance of the ultrasonic with an initial value of zero, the x distance that will be calculated by any body near the device, val is the value of mapping from the potentiometer reading. Also, I added the <servo.h> library to read the servo motor and I named it as servoMotor. Then, I set the trigger and echo of the ultrasonic sensor to be able to read the distance of any object correctly.
2. Then, in the void setup(), i begin with assigning each pin to its pin number and its state. also i attached the serial monitor code >> Serial. begin (9600) to be able to read the readings on my screen. the main switch and the slider switch 2,4 are as input pins, the RGB LEDS 9,10,11 are as output pins. the servo motor is attached to the pin 3 and the potentiometer is attached to analog in A0 pin.
3. Then through the void loop(), re const the distance as 40 cm, the distance will read from pins 7 and 6 the trigger and ECHO pins. then i made the IF condition, if the slider and the switch are on , then it is the automatic mode. in this mode the device will use the ultrasonic to calculate the distance of anybody in front of it and act as the following code. i wrote an IF condition to restrict the RGB color and the motor angle. After that, i chose the output pins 9,10,11 with High/LOW to make the light colors emitting from RGB LED. The full path can be illustrated as follows: this is done by adding the Distance order as follows:
4. then i made the IF condition, if the slider and the switch are off, then the manual mode is on. in this equation i used the analog read from the potentiometer VAL and mapping it from 0 to 100. then printing this value to the serial monitor to see the results of the readings. then i made three equations by fixing the angle to the RGB led lights to be simulated as the automatic mode but with using manual operation. Then ending the loop with the Low condition of the circuit. they are as follows:
Steps of Simulation by using Tinker cad
I used the Tinker cad to ONLY simulate the circuit.
First, I chose from the panel: the Ardunio Uno, mini breadboard, Slider Switch, Servo Motor, potentiometer, on/off switch, Ultrasonic sensor, RGB LED, and resistors of 220 ohms.
I supplied the 5 V power pin from Arduino to the + side of the Breadboard and the GRD to the -Ve side of the Breadboard respectively.
Then I settled the slider switch and connect the 2 terminals of it to the +ve and -ve sides of the breadboard. The common middle terminal to pin 2 of the Arduino.
5. i placed the RGB LED in the bread board and supplied the common cathode of it with the -Ve of the breadboard. Also for the anodes colors i crossed resistors of 220 ohms along them then to the Arduino digital pins as 9,10,11 respectively.
6. i connected the servo motor to the breadboard by supplying the power pin to the +ve and the GRD to the -Ve of the breadboard. And, the signal pin to the the Digital pin 3 on Arduino.
7.Then, i connected the ultrasonic sensor to the circuit. By supplying the power pin to the +ve and the GRD to the -Ve of the breadboard. And the Echo, trigger pins to pin 6 and 7 respectively.
Screen Shot of the Full Circuit
8. Then i added the potentiometer along +ve and GRD Arduino and the mid pin to analog pin A0. also I added the on/off switch of the whole circuit to fix the opening of the device. the switch pin is 4 and the other leg with the GRD.
9. the last step was to copy the code i made in Arduino IDE to the TinkerCad Text code type and simulate it.
Demo for the Circuit Simulation
Ex. 1: LED Toggling Riddle!
First, I chose the 1 Arduino UNO, 4 LEDs with different colors red-green-yellow-white, 1 Push Button, 1 Potentiometer, 1 Breadboard, Jumper wires, and resistors of 220 ohm.
i placed the 4 LEDs in the breadboard along the upper side.
i crossed 4 resistors along the cathodes of the 4 LEDs.
Then with using jumper wires MM i connect the GRD of the Arduino with the -Ve of the bread board.
Each color on the 4 anodes LEDs green- red-yellow-white by sequence, I supplied them to the analog pins on the Arduino Uno 3,5,6,9 respectively.
i tested the board at first with only the 4 LEDS to check whether all thing goes right or if there were a problem. but all thing goes well!
6. After that i put the push button on the lower side breadboard, i connected the -VE of the bread board to a one side of the button, the other side of it is connected via jumper wires to the Arduino pin 12. Then I tested it if it has an effect on the LEDs or not. but all thing goes well!
7. Then, i added the potentiometer i connected the -Ve of the board to the right pin side, the middle pin was connected to pin 12 on the Arduino and the last pin was connected to the Power 5V of the Arduino.
Serial Monitor Reads
Demo for the Circuit implementation
Ex. 2: LCD with KEYPAD PASSWORD!
First, I chose the 1 Arduino UNO, LCD, and a KEYPAD.
i assigned the key pad pins to the arduino uno board along pins [ROW_NUM] = {10, 9, 8, 7}; [COLUMN_NUM] = {6, 5, 4}.
3. And for the LCD pins, i assigned the GRD pin to the GRD of the arduino, the VCC of LCD to the 5V of the arduino, then the SCLand SDA to analog pins A4 and A5 of the arduino.
4.then i uploaded the code to the Arduino using the USB from laptop. i tried to type the correct code and a wrong code, to see if it works.
Demo for the Circuit implementation
3- The Smart Device Circuit implementation
First, I conducted the power by using MM jumper wires on one side along with the mini breadboard and the other on 5V of the Arduino. the same was done for the GRD side.
Then, I put the slider switch on the lower part of the breadboard. i settled the RGB LED and i placed the RGB LED in the breadboard and supplied the common cathode of it with the -Ve of the breadboard. Also for the anodes colors i crossed resistors of 220 ohms along them then to the Arduino digital pins as red, blue, green 9,10,11 respectively.
3- i connected the slider switch terminals with the Arduino by supplying the power and GRD to the upper slots in breadboard and the common pin with the Digital pin 2.
4- Then i began to connect the potentiometer to the breadboard by supplying the power and GRD to the upper slots in breadboard. And the middle pin to analog in pin A0 respectively.
5- Then i began to connect the on/off switch of the circuit to the breadboard by supplying the power line to pin 4 and GRD to the upper slots in breadboard.
6- Then i began to connect the Ultrasonic sensor to the breadboard by supplying the power and GRD to the upper slots in breadboard. And the Echo, trigger pins to pin 6 and 7 respectively. i connected the Servo motor to the circuit, by adding the power and ground of the motor to the line of the upper slots in the breadboard. Also, the signal pin to the Digital pin 3 on Arduino.
7- Then, I opened Arduino IDE after copying the code from tinker cad, and upload it to the Actual Ardunio after porting it with the USB.
Milestone 1 : Re-checking that all things are working together
Distance Readings from serial monitor
Milestone 2 : Designing the Enclosure of the Device.
First, i started to fix the servo motor on the cardboard by using the double face glue. then I removed the servo cap by using a screw and I began to fix a plastic rod 5 mm.
i used the louvers as the movable part in my device and to act the programmed code. i fixed it to the front side of the device by using cardboard and a metal wires.
3. then i placed the breadboard and the Arduino on a base cardboard by using double face glue.
4. I replaced all the components that are fixed directly on the breadboard with FF,MF wires to be extended to the marked positions.
5. then, I made a hole on the front side to place the ultrasonic sensor in it.
6. the next step was to make the holes of the switch, potentiometer, lamp and the slider then close the whole model.
Milestone 3 : DEMO of the device
Actually in the off-session exercise, i learned a new tip for modifying the circuit between manual and automatic modes. Also how to integrate different inputs and outputs in the same circuit. this will help me a lot in completion of the whole project idea.
Also in this activity Sahar who was my partner helped me in the implementation of the circuit and the connections among different inputs and outputs. i also helped with writing the code of the circuit.
i learned a new sensor type called DHT11 the sensor of the temp and humidity, and how its code is written.
A new Tip i learned from the EOweek , that we have to check the components and their power needed from the arduino or if i will supply the arduino from a charger,, so if it is higher than 5V so we have to supply it with power supply. but in this case we will add a regulator in the circuit. i also asked about the Relay module and how it works. i was taught that it may be needed to a regulator to break down the voltage used while using a high voltage components as DC motor.
Problem: In the Exercise 1 of toggling the LED lights, in my first implementation i used the For Function only without adding the IF function of digital button == low or High>>> this made the circuit as it neglects the presence of the pushbutton. After checking the serial monitor. so I tried again by myself to recheck this problem.
The solution was to add the If function at the end of the code that restrict the effect of pressing the pushbutton. If it is low then it will enter the for loop.
It reads 010101 without pressing the pushbutton
2. Problem: In the Exercise 2 of LCD screen, in my first implementation, the screen was keeping as a one row screen, also the numbers are shown as !$%^. So, i searched on google about the types and differences of each LCD , to reach the most efficient case for my LCD.
The solution was to install the LIQUIDCRYSTAL.IC2 Library not the LIQUIDCRYSTAL, and the LCD that we have will be connected to the arduino using the side 4 pins not the front 16 pins.
IT reads the LCD as only a one row not 2
ERROR: Connecting the LCD with the front 16 pins
ERROR: Connecting the LCD with the front 16 pins
Connecting the LCD with the front 16 pins
Connecting the LCD with the side 4 pins
3. Problem: In the Hands on Activity, in my first implementation, i connected all the parts as the chart given, but with no action! the relay module is only emtting a red color, i practised it again in the EOweek activity and the same problem appears. So, I asked my instructor about this issue and how to solve it!
The solution was that the relay module was fixed from the factory as a12V in so it must have been transferred to the 5V pin to the Arduino board. Then it works very well!!!
Move this part to 5 V
HANDS on ACTIVITY diagram
The EOWEEK practise Activity
Practising the coding and programming logics is my first try to go deeply in this. it helps me a lot in my weekly practice and exercises. Also this will be a great addition in my project.
In the Assignment of this week, I succeeded to do the circuit of my final project, the manual and the automatic cases in the same circuit by using a switch, slider and potentiometer to do this transferring between the 2 modes.
the most coolest thing of this week that i could Simulate my final project circuits on Arduino IDE and make sure it is functional and Build different circuits on a breadboard and test it. i also could accomplish both the manual and the automatic mode of my project.
Also, practising the smart home circuit challenge. it consists of different parameters to add in the same circuit. This was a good implementation of real application.
Practicing the Tutorials through Arduino IDE and real implementations.
I also watched some helpful videos about Ardunio uno and coding.
Practising Tutorials