Course Project
DeVry University
College of Engineering and Information Sciences
Course Number: CEIS101C
Background
The Internet of Things (IoT) is growing exponentially. New technologies and applications are
being developed regularly, creating many new job opportunities, each with its requisite skill sets.
It is important to stay current with the skills required for this evolving job market and to take
advantage of the many available learning opportunities currently available. This course project
covers the fundamental concept of the IoT by integrating hardware, software, and networks into
an entire system. The project is divided into six parts where each part builds upon the previous
resulting in an IoT device that will simulate a smart home automation and security system. The
design and development process of this project truly encompasses various aspects of the IoT and
will prepare you for your future career in technology.
Scenario
Develop a smart home automation and security system by designing the prototype and
programming using a virtual emulator. The smart home system will encompass various devices
to monitor the condition of the home. This includes a door sensor to check whether to door is
open or closed, a distance sensor to monitor for a home intruder, and automated lights that turn
on when it is dark. Optional components can be added to the smart home system including a
water level sensor to monitor for flooding and a temperature and humidity sensor to monitor the
weather.
Module 6: Adding Automated Light to Smart Home System
Objectives
To learn how to connect a light sensor to the Arduino board
To learn how to write code that uses a light sensor
To learn how to write code that turns on light based on the reading from the
light sensor
Deliverables
Complete the Module 6 Course Project PowerPoint Deliverable
Include a picture of completed circuit with automated light off (10 points)
Include a picture of complete circuit with automated light on (20 points)
Include a screenshot of code with your name shown (10 points)
Include a screenshot of serial monitor with messages displayed (20 points)
Step 1) Duplicate your Tinkercad project from Module 5 with the ultrasonic
sensor, buzzer, and red, yellow, and green LEDs. You will be adding the photocell,
also known as a light-dependent resistor or photoresistor, to the system to act as
our light sensor.
This light sensor is really a resistor whose value changes depending on the
intensity of the amount of light that hits it. By putting it in series with another
resistor and feeding both a DC voltage, a voltage drop is created. The amount of
voltage that appears across either one of these resistors depends on the value of the
resistor itself.
Since the value of the light sensor changes according to the intensity of the amount
of light it receives, its voltage will also change accordingly. The Arduino board has
analog inputs that can read an input voltage and convert it into a number. Thus,
number is directly proportional to the intensity of light received by the light sensor.
Based on the readings that will be shown in the Serial Monitor we will control the
condition at which the automated light will turn on.
Step 2) Referencing the circuit schematic below, search the Component Search for
the photocell and wire it as follow
Add an LED to the breadboard and change the color to Blue LED
The longer lead of the blue LED connects to pin 9 on the Arduino Board and
the shorter lead of the LED connects to the ground (-) rail of the breadboard.
Add a 10 kΩ resistor to the breadboard
Step 3) Open the Text mode in Tinkercad, erase all the contents in the sketch and replace it with
the code shown below. In the code, replace the xxxxx with your name. Upload the code and Start
Simulation.
#define trigPin 8
#define echoPin 7
#define Rled 2
#define Yled 3
#define Gled 4
#define buzzer 10
#define photocell A0
#define autoLight 6
void setup() {
[Link](9600);
[Link]("CEIS101C Course Project Module 6");
[Link]("Name: xxxxx "); //replace xxxxx with your name
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(Rled, OUTPUT);
pinMode(Yled, OUTPUT);
pinMode(Gled, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(autoLight, OUTPUT);
}
void loop() {
//=== Automated Light ===
int value=analogRead(photocell); // Read the value from the light sensor to determine condition
//[Link](value); //uncomment this line and open serial plotter to see the effect of light
intensity on the sensor
if (value > 450) {
digitalWrite(autoLight, HIGH);
[Link]("The automated light is ON");
}
else {
digitalWrite(autoLight, LOW);
}
//==== Distance Sensor ===
long duration, distance, inches;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the echo signal
duration = pulseIn(echoPin, HIGH); // Read duration for roundtrip distance
distance = (duration /2) * 0.0135 ; // Convert duration to one way distance in units of inches
if (distance <= 12) { // Outer IF statement units of inches
if (distance <=6){ // Alert range condition
[Link]("Alert! Possible Intruder.");
digitalWrite(Rled, HIGH); // Alert green LED on
digitalWrite(Yled, LOW);
digitalWrite(Gled, LOW);
}
if (distance <12 and distance > 6){ // Warning range condition
digitalWrite(Rled, LOW);
digitalWrite(Yled, HIGH); // Warning yellow LED on
digitalWrite(Gled, LOW);
}
//==================== Beeping Rate Code Start ======
tone(buzzer,500);
for (int i= distance; i>0; i--)
delay(10);
noTone(buzzer);
for (int i= distance; i>0; i--)
delay(10);
//==================== Beeping Rate Code End =======
}
else{ //Safe range condition
digitalWrite(Rled, LOW);
digitalWrite(Yled, LOW);
digitalWrite(Gled, HIGH); // Safe distance green LED on
noTone(buzzer);
}// end of outer IF statement
delay(100); //pause program to stabilize ultrasonic sensor readings
} //end of loop
Step 4) Upload the code and use the slider near the photocell to adjust the light. Watch the light
turn on when it gets dark and off when it gets light.
Take a picture of the blue LED on and include it in your PowerPoint Deliverable.
Take a picture of the blue LED off and include it in your PowerPoint Deliverable.
Move the slider to adjust the light
level.
Step 5) Open the Serial Monitor and continue testing the smart home system by slidering the
slider.
Take a screenshot of the Serial Monitor and include this screenshot in your PowerPoint
Deliverable.
Step 6) Submit the PowerPoint Deliverable.