components used to build the project
Task Description as mentioned on the portal:
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
Ideation: I have to admit that this topic of programming is so challenging for me. I will not exaggerate when saying I had a hard time thinking of this even before starting. Surprisingly after watching the videos and getting help from my colleagues in the diploma, I started having more ambitions to explore creativity in this area but I reminded myself I am already behind the schedule and I aimed for something doable at the end which is controlling a LED light using an ultra-sonic sensor and an Arduino board.
I can imagine this sensor being hanged on the kitchen door and when my brother tries to sneak into the kitchen after midnight, the LED bulb will glow in my room and I go quickly to save the poor food in the fridge.
Thinkercad to simulate the circuit and build the code
Arduino IDE to upload the code on the circuit
electric components to build the circuit
Steps of designing the circuit before fabrication:
Connecting the components and making sure I used the right wiring and it is actually functioning.
I used the code blocks to write the code, and I made sure that I used the right pin numbers.
Copying the code from Thinkercad to Arduino IDE software.
Step 1: connecting components on Thinkercad
Step 2: adding the code blocks
Step 3: copying code to Arduino software
More on coding with the code blocks:
Coding reminds me of telling bedtime stories to my niece and nephew, especially when trying to imagine conversations or events that never exist. When coding, I always build an imaginary conversation between me and myself trying to figure out the sequence of the features I want to implement and how this can be translated to inputs and outputs in the programming language.
As for this project, I started by picking the "if condition" from the control menu block as the ultrasonic sensor (input) is the boss of the circuit meaning that everything starts and ends from where he is, then defined the sensor from the input menu and the rest of the equation from the math menu.
3. I made sure the pin number in the code matches the pin number on the board where I connected the sensor. Then came the challenge of setting the right value of the distance between the sensor and the object which should be compatible with the application since I want to use it to detect my brother getting into the kitchen at midnight and my intention is to save the food. I think thirty cm should be enough in this situation.
4. Then I asked myself what will happen if my brother crossed the range of the ultrasonic sensor (thirty cm) and how this can be visualized in a form of output. Here come the LED bulbs (outputs) that will glow when he gets closer and will remain off when the area is safe and empty from any attacks.
5. Before moving to Arduino IDE to upload the code on the board, I tested the sensor and whether the wiring I did was the correct way of linking the components or not, and it was a happy moment to see the code in action and circuit works!!
127.2 cm far from the sensor l LED is turned off
17.7 cm far from the sensor l LED is turned on
Step 1: building what I did on Thinkercad using the actual components.
Step 2: testing components and making sure the sensor works and the LED glows when I get closer.
testing the ultrasonic sensor and the LED light's reaction when I get closer
I was not really sure about picking the right sensor on Thinkercad and after referring to the video tutorials again I remembered the instructor using the four pins' sensor.
I was impressed by the fact that there is an option called "code blocks" this will definitely give me so much confidence as a designer to build and understand code and to try things that I always wanted to do but did not have enough technical knowledge for them including the final project I have in my mind.