Due: Wednesday 1/28/15 at 1:15pm
Submission checklist
Make sure your google site is visible, at least to MHC users
Check that the Assignment 1: photoresistor page has a video of your project working
Upload your Arduino sketch (.ino) to moodle
Overview
In this assignment, you will:
set up your google site for the course
create an Arduino project that uses photoresistors to light three different LEDs
Resources
Simple photoresistor example that shows how to read ambient light values from a photoresistor
Create a google site for this course -- please name it CS 243 Spring '15 - yourUsername. For example, mine would be CS 243 Spring '15 - astjohn.
Under the Settings (gear) menu, select Sharing and Permissions. By default, your site will be Private; click Change... to change to one of the following (your choice)
Public on the web
Anyone with the link
Mount Holyoke College
People at Mount Holyoke College with the link
Step 1
First, work through the Simple photoresistor example that shows how to read ambient light values from a photoresistor.
You should inspect the Serial monitor to see how the values change.
What value range do you see with average lighting conditions?
What value range do you see when you cover the photoresistor?
What value range do you see when shining a bright light (try the flashlight of your phone, for example) at the photoresistor?
Step 2
Following what we did with the Advanced HC-SR04 (distance sensor) example, create an Arduino project that compares the light values from 2 photoresistors and displays the status using 3 LEDs..
You will need to create a sketch that compares the light sensed by the photoresistors and lights the LEDs accordingly. You should allow for some threshold to say when the light values are considered different.
Hardware requirements
Your project should be consistent with the following diagram.
You will need the following components:
2 x photoresistor
2 x 10k ohm resistor
3 x LEDs (pick the same color)
1 x 200 ohm resistor
1 x Arduino Uno
1 x breadboard
jumper wires
Software requirements
Your Arduino sketch must have
the following variables:
lightDifferenceThreshold
two light readings that differ by less than this value are considered the same
use what you learned in Step 2 to pick a value
3 booleans (leftBrighter, sameBrightness, rightBrighter) to track the status for
if there is more light from the left photoresistor
if the two photoresistors are reading the same light (within the threshold)
if there is more light from the right photoresistor
3 (digital) pin assignments for
an LED that lights if there is more light from the left
an LED that lights if there is the same light from both
an LED that lights if there is more light from the right
2 (analog) pin assignments for
a left photoresistor reading
a right photoresistor reading
2 values to store
the value read from the left photoresistor
the value read from the right photoresistor
hint: you may wish to refer to the Arduino language reference (API) to determine the type for these variables
the following methods
setup
initialize Serial monitor
initialize status variables to false
assign LED pins as OUTPUT
assign photoresistor pins as INPUT
loop
determine light readings and update status variables
update the output LEDs
wait 500 ms
determineLightAndUpdateStatus
read the light values from both photoresistors
print values
hint: you may wish to use Serial.print and Serial.println to get values on one line; only Serial.println will end with a newline
compute the difference between the two values
compare (using the threshold) to update the status variables appropriately
updateOutput
based on the status variables, light the LEDs appropriately
lightLED
you may wish to copy this function from the distance sensor example as a helper function
Step 3
Create a new page on your google site called Assignment 1: photoresistor that
lists the required components
contains a short video (using a smartphone or lab computer -- you can use PhotoBooth to create a video) of your project in action
Submit your final Arduino sketch (.ino) on moodle. Do not post it on your google site!