Inspiration
The assignment requirements are designing a smart project by using Arduino by implementing inputs and outputs and using code blocks to control the system or the idea.
Inspiration
I decided to design an alert birds system in 2 different conditions.
1st when any danger closes from their cage the alert system should work by buzzing, waving ambient light and supplying air to distract the nearest danger such as rats or any vultures.
2nd Is alerting system for summer time because by increasing temperature it might harm Birds so I meged another feature in my system to alert me by increasing temperature more than 30 Celsius to take an action or splash some water.
Software tool:
Tinker cad online tool is pretty useful for designing the circuits where I can test the results easily, to avoid any mistakes before the actual test on the bred board.
Arduino IDE for Mac Os
coding and programming hardware components need an intermediate tool to adjust and to operate the code on the electronic circuits. Arduino IDE is doing this function.
Hard ware tools
1 bread board
1 DC fan
2 ultrasonic sensors.
1 Buzzer
1 RGB
Arduino Uno
Jumper wires.
Temperature sensor L35
Arduino USB wire.
3 resistors each one with 220 Ohm.
Electronic components and their powering source
Temperature sensor LM35
Ultrasonic sensor is powered by 5
Buzzer powered by 5 volt
DC fan powerd by 5 V
Arduino Uno powered by 9V
RGB with common cathode powered by 1.5 V
bread board
Jumper wires
Resistor 220 Ohm
Software tools
Arduino IDE for Mac Os
Software design process
open Tinker Cad on line tool and drag all needed components.
Starting with ground wire from all components (2 US sensors, Fan, Buzzer, Temperature sensor and RGB LED).
Unifying the ground by taking a black wire from all components and connect it with the board then from the board to the GND in Arduino Uno.
connecting all +ve of both L35 and 2 ultrasonic sensors with 5V in Arduino.
Temperature sensor needs to be connected on an analog connection (5A).
3 resistors 220 Ohm are connected to the RGB LED except the common cathode pin it is connected with the ground.
Each Ultrasonic sensor has TRIG and ECHO pins which are connected with digital link.
Finally
both +ves of buzzer and Fan are connected to digital link as well.
Hard ware Preparation process
This step act as a mimicry step for the tinker cad.
Preparing all components and fix them on the board.
Starting with the same sequence in Tinker cad.
Checking all connection after each single step before writing the code or any semulation.
Software implementation process
Tinker cad coding
Open blocks in tinker cad and starting to write the code.
Picking an If then els condition from the control category.
Drag (return true if one of the inputs at least is true).
I need to insert 3 inputs and any one of these inputs is true the out puts (Fan, buzzer and RGB) should work.
Drag the block of reading ultrasonic sensors at distance less than 30 cm.
Set the temperature sensor to work at temperature greater than 30 cm.
Set the output by dragging Set pen High or low.
Set pen 1,2,8,9 are high as they RGB, buzzer and fan
Alternate the RGB pens to give a different light colors by setting pin 8,10 high while 8 is low.
Finally, Set the else condition where if non of the previous inputs is true ==> Shut all system outputs.
Arduino IDE
Compiling the system on tinker cad by clicking on simulation.
After working the system properly, copying the code as a text from tinker cad.
Open Arduino IDE and upload the code on it to start the actual first trial of the system.
Before void setup
Set variable as long type to carry data from ultrasonic
long readUltrasonicDistance(int triggerPin, int echoPin)
Identify each trigger and echo pens whether input or output
pinMode(triggerPin, OUTPUT);
set echo pin input as it return data to the ultrasonic sensor.
pinMode(echoPin, INPUT);
Void setup
Identify each component on each pin by using pinMode function
pinMode(A5, INPUT); for LM 35 temperature sensor
pinMode(1, OUTPUT); fro Buzzer
pinMode(2, OUTPUT); fro Dc fan
pinMode(8, OUTPUT); for RGB
pinMode(9, OUTPUT); for RGB
pinMode(10, OUTPUT); for RGB
void loop
The code starts by checking the distance that has been returned by the echo pin as the following
1- If the returned distance on both ultrasonic sensors is less than 30 cm the buzzer on pin 1 is alert and the the fan on pin 2 rotates. and the RGB lights up
2- If the temperature that received by LM35 sensor is > 30 C also, buzzer, Dc fan and RGB are on.
Hardware implementation process
Check all wires and components are connected properly, to the board.
check the connection between Arduino Uno and the board by following Tinker Cad simulation.
connect the Arduino Uno with USB cable which connected to the lab.
Upload the code and test the prototype / or the alert system.
Check the problems if one of the components does not work.
first challenge
After connecting all components and simulate the prototype on Tinker Cad I pressed upload the code on Arduino IDE however, The out puts did not work.
solution
I made a double check on the connection then I found that I did not connect the common ground from all fixed components on the board to Arduino Uno. The problem has been solved.
Second challenge
The system should stop If all inputs did not receive any stimuli from the environment ()distance less than 30 cm / or Temperature > 30 celsius).
solution
I rechecked the code again and I found that I did not set code in the else condition. I copied the code then set all pins low (1,8,9,10) and the problem hase been solved
In /Out Differentiation
I surprised by myself that I could add more than one input and outputs in the same time and thinking in writing code easily, so I think this week is the backbone of my final project because now I know how to connect the moisture sensor and to code it such as any other sensor.
Moisture sensor connection
I was fascinated to write the code for count down 7 segment components and the wavy hand design at the end of week.