This Week assignment's is to Build and Program a smart circuit using an Arduino UNO which reads a signal from an input component (Sensor, Switch, or variable resistor) to control an action component (Motor, Buzzer, LED...etc) using Code Blocks.
I searched in Google about ideas to do this assignment and i found a project of
Arduino Touch Piano
because I loved how this circuit used Photoresistors sensor instead of push button as a touch button.
This smart circuit includes
Input component from Photoresistor sensors by touching the sensors to change the amount of light reaching it.
Give Two action component output the first is a three tone sounds from Buzzer and the second action is a red or green or blue light from RGB LED according to the touched Photoresistor sensor.
Software :
1- TinkerCad Portal : to build and simulate the circuit online
2- The open-source Arduino Software (IDE) : to write code and upload it to the Arduino board.
Materials :
1- Breadboard
2- Jumpers to connect the component
3- Arduino Board + USB cable
4- Three resistors 220 Ohm.
5- Three resistors 10K Ohm.
6- One Buzzer
7- Three Photoresistors
8- One RGB LED
Tinkercad portal
Arduino IDE
First Step :
The Circuit :
1- Open the TinkerCad Portal.
2- Drag and drop this component ( Arduino Uno - Bread Board - buzzer - photoresistor - 10K Ohm Resistor )
3- Connect 5V and GND Pins for arduino to The two rows ( + and - ) of bread board.
4- Connect the Buzzer : The negative leg to ground raw and the Positive leg to Digital Pin 3 ( Output).
5- Connect the Photoresistor : the terminal 1 to the 5v raw and terminal 2 to 10K Ohm resistor and connect the same terminal 2 to Pin A0 ( analog input) , the other leg of resistor go to GND raw.
Input component: Photoresistor
Action component: Buzzer
CODEBLOCKS:
IF .. Else condition to control buzzer tone by touching photoresistor sensor.
When analog pin A0 read a Value smaller than 300 ( when becomes Dark Due to put a finger on the photoresistor ) --> the Buzzer (speaker) on Pin 3 give a tone sound 60 for 1 second.
else the buzzer on Pin 3 turn off .
The first Curcuit on TinkerCad
Code Block of the first circuit
simulation of the first circuit
Second Step :
1- Duplicate the pervious steps to add 2 other Photoresistor sensors in parallel .
Photoresistor sensor 2 on Analog Pin A1.
Photoresistor sensor3 on Analog Pin A2.
CODEBLOCKS
1- in the pervious else Block , Duplicate the all pervious code blocks and change the analog bin A0 to A1 and change the buzzer tone to 80 .
2- in the second else Block duplicate the same code blocks and change the analog pin to A2 and change the tone to 100.
3- in the last else the buzzer on Pin 3 turn off.
Code Block of the second curcuit
The second Curcuit on TinkerCad
simulation of the second circuit
Third Step :
add a RGB Led in parallel to the circuit ( the cathode leg go to GND raw and the other 3 legs go to 3 resistors (220 Ohm) then the other resistors legs go to Digital Pins 5 , 6 , 9 on arduino board.
CODEBLOCKS
1- in the first if condition add 3 blocks to set pin 5 to HIGH and pin 6 and 9 to LOW ( to light the green light in RGB LED when we touch the photoresistor sensor 1).
2- in the second if condition add 3 blocks to set pin 6 to HIGH and pin 5 and 9 to LOW ( to light the Blue light in RGB LED when we touch the photoresistor sensor 2).
3- in the third if condition add 3 blocks to set pin 9 to HIGH and pin 5 and 6to LOW ( to light the Red light in RGB LED when we touch the photoresistor sensor 3).
Code Block of the final circuit
The final Curcuit on TinkerCad
1- Do the Same circuit by the same component physically on actual Arduino board .
( Breadboard - Jumpers to connect the component - Arduino Board - Three resistors 220 Ohm- Three resistors 10K Ohm- One Buzzer - Three Photoresistors - One RGB LED ) as shown in the images.
2- connect the Arduino board to the computer by USB cable.
3- Open the Arduino IDE Program.
4- from TinkerCad Portal go to Code and Blocks and Copy the C++ code from it then past it in the Arduino IDE program.
5- Upload the code to the Arduino Board.
6- Touch the photoresistor sensors by your finger and hear the tone from the buzzer and see the light from RGB led as shown in this video:
image of the circuit of the Actual Arduino board and the other electronic components
Control 7-segment display by Arduino
Video of Control 7-segment display by Arduino
control RGB LED by Arduino
Video of Control RGB LED by Arduino
We divided into teams , I participate with Mohamed Tarek in a learning activity to practice controlling electronics with Arduino
Exercise 1: Program Arduino board to control one 7-segment display so that it counts down from 9 to 1
I drive Mohamed Tarek to simulate the circuit in tinkercad and we used 7 resistors ( 220 Ohm) to connect the 7 segment display to 7 digital pins.
then he build and test the circuit on a physical breadboard and it works fine.
in Exercise 2: Program Arduino board to control one RGB LED so that it lights up with the following colors in order: Red, Blue, Green, Purple, Orange, and White
Mohamed Tarek drive me to do the exercise.
we used Three 220 ohm resistor to connect the 3 legs of RGB led then simulate the circuit on TinkerCad
then I build and test the circuits on a physical breadboard and it works fine also and in the time.
it was Great team work and we have a lot of help to each other to complete this exercises in time and after the session we shared our codes ,images and video to document it.
Control Servo motor by moving potentiometer and Arduino
Code Blocks in tinkercad
Video of simulating
Video of actual Circuit
We divided into teams , I participate with Rawan Sorour to Build a Smart Waving Hand using Arduino. 1- for the Manual Mode: We use a servo motor attached with hand from paper as output is controlled manually by using a potentiometer as input of Arduino board.
We started with draw the circuit in tinkercad and write the code then simulate it as shown in the pictures and video and it works fine.
But when do it Physically in actual arduino it didn't work because there are a problem in our potentiometer.
Our instructor Amani Ayman helped us to replace the potentiometer by another one and write the right code in tinkercad and the circuit works fine.
thanks for Amani Ayman and Rawan Sorour for great help.
When I chose this circuit to do it i don't Know how to connect the photoresistor sensor to the arduino board then i searched on google for it and i found this site :
https://www.instructables.com/Light-Sensor-Photoresistor-Arduino-Tinkercad/
it had a good information about this circuit and it helps me a lot.
and i found this video about ( LED Control with LDR (Photoresistor) and Arduino ) which helped me to do that assignment.
I'll use tinkercad portal to design and simulate and code the final project circuit before i do it physically and i will use the experiences from this week to do the electronic circuit and write the code for the final project.
Control Servo motor by moving potentiometer and Arduino
Code Blocks in tinkercad
Video of actual Circuit
We divided into teams , I participate with Rawan Sorour to Build a Smart Waving Hand using Arduino. 1- for the Automatic Mode We use a servo motor attached with hand from paper as output is controlled by using a Ultrasonic Sensor as input of Arduino board.
We started with draw the circuit in tinkercad and write the code then simulate it as shown in the pictures and video and it works fine.
But when do it Physically in actual arduino it didn't work because we use digital pin as input and after ask Amani Ayman, she told us to change the eco leg for ultrasonic from the digital pin to analog pin input A0 and finally the circuit works very good.
and Ibrahim Raafat Explain to us how PWM pins works.
Video of simulating
Title of Media