By the end of week 7, you will be able to:
Understand Arduino Code structure and write Arduino C code syntax correctly
Create and Use Variables to store and manipulate different types of date in Arduino C
Use Looping (For) for repeating actions in Arduino C
Create and use Functions in Arduino C
It’s so ordinary and boring to just have a normal Desk Lamp to just turn it on and off by a switch! What if it was smarter and senses your presence! To just sit on your desk and Voila! The lamp turns ON, and once you move away, it turns OFF. This is your chance to try and build your first Smart Desk Lamp!
This smart Desk lamp works in Two Modes: Manual Mode and Automatic Mode:
The Manual mode means that you manually control the Desk lamp using a regular ON/OFF Switch.
The Automatic mode means that the Desk lamp is automatically controlled: If the IR sensor is sensing the presence of a person near the lamp, it keeps the lamp ON. If the IR sensor is not sensing the presence of a person in the room, it turns the Desk lamp OFF.
Type: Individual Activity
Tools & Materials:
1 Arduino UNO
1 LED (Represents the Desk Lamp)
2 Slide switches (1 switch represents the Mode selector and 1 switch represents the Desk Lamp's ON/OFF Switch)
1 IR Sensor module
1 DC adaptor
1 Breadboard
Description
We will be making this activity using Divide and Conquer Technique!
Manual Mode:
Build the manual mode circuit using a slide switch and LED (View Circuit Wiring)
[Hint: use a 3 pin slide switch]
Build your code to control the LED using the switch ON/OFF (Use Block Code on Tinkercad)
Automatic Mode:
Build the Automatic mode circuit using IR sensor and LED (View Circuit Wiring)
[Hint: you can replace IR sensor inside Tinkercad with PIR sensor as Tinkercad doesn’t have IR sensor]
Build your code to control the LED using the IR sensor
Adding selector and merging 2 codes together:
Add a slide switch (3 pin) to your circuit to choose between the two modes (View Circuit Wiring)
Build your code so that the slide switch (selector) chooses between manual and automatic modes
Reflect & Share
How did you write the code to control your smart lamp solution? Please explain in detail.
Did it work as it was supposed to? Why?
What challenges did you face while writing and testing your code?
Follow the video tutorials below (in order) to learn how to program an Arduino UNO to control input components and action components using Text code (in Arduino C). View the Code Library to follow along.
Arduino Code Structure & Syntax
Loops & If Conditions
Deadline: Before Midweek Session
Mode: Online via Google Meet
Session Outcomes
Discuss video tutorials and address challenges or problems with your instructor
Participate in a pair programming activity to program a smart circuit using Arduino C Language
Participate in an Activity to Find the bugs in Arduino project software
Session Exercises
Exercise 1: Make a Smart Temperature Indicator circuit using Arduino (This circuit could be part of a device that is sensitive to temperature changes).
(Expand to view Description & Requirements)
Description: The smart temperature indicator uses an LM35 sensor at the input and an LED at the output. The LM35 sensor senses the temperature and the circuit indicate one of three states:
LED is OFF and “COOL” message is displayed on the Serial Monitor when the temperature is higher than 15 AND less than 20
LED is ON and “HOT” message is displayed on the Serial Monitor when the temperature is higher than 20 AND less than 30
LED is blinking (ON & OFF Continuously) and “Error” message is displayed on the Serial Monitor when the temperature is lower than 15 OR higher than 30
Hint: Google search “Logical AND” and “Logical OR”
Requirements:
Use TinkerCad to develop Circuit Wiring only (since LM35 doesn’t exist in Tinkercad)
Build the circuit and make your connections on a physical breadboard with an Arduino UNO Board.
Write the Code: Use Arduino C text code PRIMARILY to write your code in Arduino IDE
Upload the code to your Arduino Board
Test your Smart Temperature Indicator:
To lower the temperature: grab any frozen objects from the freezer and put it near the temperature sensor
To raise the temperature: blow hot air from your mouth at the sensor or put the sensor near a hot cup of tea.
Debug: the serial monitor is your friend! Display the current temperature regardless of the state, to be able to track changes in temperature and debug for problems
WARNING: Avoid the leakage of any liquids or using any flame source on your electronic circuit!
[Solution] Wiring & Arduino Code
Exercise 2: Find the "Bug"!
(Expand to view Description & Requirements)
Description: you will be presented with a set of “buggy” codes that you need to “debug”. The project is not working, and you need to find the bug(s)!
Requirements:
Open the Tinkercad project sent by your instructor
Click "Copy and Tinker" to have your own copy of the project
Simulate the circuit to observe the behavior (No need to build the Physical Circuit)
Download the .ino code, open in Arduino IDE, and compile the code to find errors
Utilize the serial monitor to find the bugs whenever possible
[Solution]
Bug #1: Syntax Errors
Solution Tutorials - Wiring & Arduino Code
Bug #2: Incorrect Boolean Expression (If Condition)
Solution Tutorial - Wiring & Arduino Code
Bug #3: Incorrect Statement (If Condition)
Solution Tutorial - Wiring & Arduino Code
Bug #4: Incorrect Pin Assignment
Solution Tutorial - Wiring & Arduino Code
Bug #5: Incorrect Boolean Expression (For Loop)
Follow the video tutorials below (in order) to explore various use cases of Arduino UNO in real-life projects and applications. View the Code and Wiring to follow along.
Exploring New Data Types: Char, String, and Array
[Optional] Creating and Writing Functions in Arduino C
Deadline: Before EOWeek Session
Mode: Face-to-face @ Fab Lab
Session Outcomes
Discuss video tutorials and address challenges or problems with the instructor
Participate in a group exercise to practice Arduino programming in a mini-project
Discuss assignment progress: concept and execution
Session Exercises
Smart Home System
Build a simple representation of a smart home system. This system senses the light in a room, as well as, weather parameters (temperature and humidity) in order to control a DC fan and a DC lamp.
(Expand to view Description & Requirements)
Tools & Materials: 1 DC Lamp - 2 Relay Modules - 1 DC Fan - 2 ON/OFF Switch - Jumper Wires - Crocodile Wires - 1 DHT Sensor - 1 Microwave Sensor - 1 LDR Module - 9V Adaptor - 5V Adaptor - 1 Arduino Uno - 2 Large Breadboards - 1 Slide Switch
Requirements:
You are required to build and program two modes; Manual and Automatic, using a slide switch:
Manual Mode: In this mode, A person can simply control the DC lamp ON/OFF) using an ON\OFF switch at the input. And the DC Fan using another ON\OFF switch also connected at the input of the Arduino board.
[Hint] Use Google to learn how a Relay Module Works.
Automatic Mode: In this mode, the LDR sensor would check for light in the room, if it is dark, the Lamp will turn ON, or otherwise it stays OFF. On the other hand, the DHT sensor would check the temperature and humidity levels in order to control the DC fan and put it into one of two states:
Fan is ON when Temperature is higher than 40 or Humidity is higher than 80
Fan is OFF otherwise
[Hint] you need to test the DHT sensor first by installing its library from Arduino IDE, then use the tester code.
Mode Selection: through this feature a person can simply choose the mode that they need at a certain moment, either Manual or Automatic, using a slide switch (3 Pin)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
[Extra] Automatic Mode: incorporate a Microwave Sensor into the Automatic Mode so that it checks for the presence of a person in the room:
The room is empty: DC Fan and DC Lamp are both OFF
There is a person in the room: DC Fan and DC Lamp will be ON or OFF based on the current LDR sensor and the DHT sensor values
[Solution]
Design and program a smart device that perform a certain function or solve a problem: program Arduino UNO to read signals from multiple input components (Sensor, Switch, or variable resistor) to control multiple action components (Motor, Buzzer, LED...etc) using Arduino C (Text Code).
Description:
Find any exciting idea to do for the assignment: you may find cool ideas on Instructables and Arduino Project Hub or try to implement your final project idea 😉
(Please Don't repeat any of the ideas from week tutorial examples or exercises, as it will not be accepted)
Google your idea and see how other people have wrote their code, and provide links to other codes that you've tweaked or reused in your assignment
Use Arduino C Text PRIMARILY to write your code in Arduino IDE
Technical Requirements:
The smart device utilizes the Arduino UNO board to control the inputs and outputs
The smart device includes two input components (at least) and two action components (at least)
(DON'T repeat any of the input and output combinations that were provided in the tutorials and exercises, you are encouraged to try new ones, you may also use new input and output components from your electronics kit)
The smart device is programmed using Arduino C (Text Code) (Provide a screenshot of your Arduino C code, *.ino code file, and wiring diagram)
The smart device is wired and tested with an actual Arduino board and electronic components on a breadboard (Provide a video recording of the final outcome)
The smart device has an enclosure from cardboard and the non-electric parts are prototyped from cardboard or any scrap material (You are not required to use any CAD or digital fabrication)
The smart device is functional and does its intended objective
Make sure to document your Assignment for Week 7 in the Maker Journal covering the following requirements:
Process Documentation:
Ideation: Describe how you came up with the idea for the smart device. Were you inspired by a certain reference? or did you customize design it to fulfil a certain objective?
Tools: Describe software, components, materials, and tools that you used in your assignment
Design: Describe the design of your smart device. What are the input and action components that you used? Make sure to include a screenshot of your circuit wiring on Tinkercad or any other software (Fritzing or Microsoft PowerPoint). Explain your Arduino C code in detail, describe the code that you wrote using simple text, Pseudocode, or Flowchart format
Implementation/Fabrication: Describe how you implemented your smart circuit on a breadboard and integrated the components within the enclosure. And most importantly, show us the final outcome of the assignment, make sure to include a video recording for your complete smart circuit in action
Media: Provide supporting images and videos to demonstrate the design and implementation processes
Learning Documentation:
Learning from Mistakes: Describe problems and challenges that you faced, and briefly describe solutions. How did you debug your code for error?
Community of Learning: Highlight an advice or idea provided by a peer or an instructor that helped in solving a problem or a challenge. Or an advice that YOU provided to help your peer(s)
Progress Review Deadline: February 10th, 2025 @4:00 PM