CS 353 Jan 2025     Syllabus       Labs/Projects

Lab Goals Part 0: Software Setup Part 1: LED Part 2:
IR LED
Part 3:
IR Detector
Part 4:
IR Switch
Check-in

Lab 1: Infrared Switch

Goals

  • Wire a circuit.
  • Calculate the required resistor for an IR LED.
  • Program a micro-controller.
  • Read from a sensor and write it to the Serial Port.
  • Build a switch that turns on an off an LED by blocking the path between an Infrared LED and Infrared Detector.

Part 0: Software Install

Arduino Install Instructions on Personal Computer

On your personal computer, Download Arduino IDE 2.3.4 for your specific operating system. Click "Just Download" twice. Download Link

Arduino Install Instructions on Lab Computers

  • On your personal computer, Download Arduino IDE 2.3.4 Linux AppImage 64 bits. Click "Just Download" twice. Download Link
  • Connect to your Personal Drive on Filer
  • Navigate to Personal/[colbyusername]/Desktop
  • Drag and drop the AppImage from your downloads to the Desktop folder
  • Login to a Dwarf to make sure the application is on your Desktop.

Part 1: LED

We will be building the LED circuit described in:
Ch 5. Electricity and Metering of Learn Electronics with Arduino



Italian Trulli

First, figure out which resistor is the 220-ohm resistor


Italian Trulli

Italian Trulli

Next, build the circuit


  1. Attach one end of a jumper to the 5V pin on the Arduino, and the other end of the jumper to the power bus on your breadboard (that’s the column marked with a red +).
  2. Grab another jumper and attach one end to the GND pin on the Arduino, and the other end to the ground bus on your breadboard (that’s the column marked with the green –).
  3. Connect a jumper from the power bus to a row of tie points.
  4. Connect one lead of a 220-ohm resistor to the same row of tie points. The other end goes in another row of tie points.
  5. Connect the anode (long leg) of the LED to the other lead of the resistor.
  6. Attach a jumper from the cathode (short leg) of the LED to the ground bus.


Italian Trulli

Part 2: Infrared LED

Italian Trulli

Build a circuit to power the Infrared LED

The infrared emitter is a light emitting diode (LED) that specifically emits near-infrared light (just below the visible spectrum).

  • Using Ohm's Law, calculate the resistor required for the infrared LED.
  • Remember in a series circuit, the current that flows through each of the components is the same.
  • Use the IR LED datasheet to look up it's maximum Continuous Forward Current and the Typical Forward Voltage associated with the maximum Continuous Forward Current.
  • Replace the red LED with the IR LED, and the 220-ohm resistor with your newly calculated resistor.
Equations
  • Vresistor = Iresistor * Rresistor
  • Vpower = VIR LED + Vresistor

Part 3: Infrared Detector

Build a circuit to read from an Infrared Detector

Given the infrared-sensitive phototransistor, build the circuit below.

A phototransistor is a sensor that is able to detect light levels and alter the current flowing between emitter and collector according to the level of light it receives.

The component with the red dot on top is the IR Detector. Use a 10k resistor for the IR Detector Circuit.


Italian Trulli Italian Trulli

Connect to the Metro Mini

  • Using a micro USB cable, plug your arduino into the computer.
  • Specify the Board as an Adafruit Metro and the USB Port.
  • Italian Trulli
    Italian Trulli

Read the signal from the Infrared Detector and write Serial

There are two built in functions, setup() which runs once at the beginning and loop() which runs repeatedly.
  • Have the Metro Mini start the Serial Port in the setup function by adding the line Serial.begin(9600);
  • Read from the analog input pin in the loop by assigning analogRead(A0) to a variable.
  • Print the value to the serial port using Serial.println(...)
  • Upload code to the Metro Mini using command-U or ctrl-U.
  • Open the serial port monitor using shift-command-M or shift-ctrl-M.
  • Save your code!

Hint: Make sure your IR LED and IR Detector are facing each other (there is a bump on the front).

Part 4: Programming an Infrared Switch

Program an Infrared Switch

Write a program that changes the built-in LED state (toggle on/off) when the path between the Infrared LED and Infrared Detector is blocked. When the path is no longer blocked the LED does not change.

The Arduino IDE has example code on how to turn on and off the built-in LED. You can find it in File > Examples > 01.Basics > Blink

Check-in

Check-in

The goal is for you to have the Infrared Switch working by the check-in. It's okay if you don't, just submit a check-in (video&doc) of what you have done so far and you'll receive 75% on the check-in (-2.5% of your project grade). You can only turn in extensions if your check-in is submitted on time and all steps have been completed.

Submit your code on Filer

Submit your arduino code in a folder titled [your username]_[your partner's username]_L01 (with your colby username, mine would be hewolfe_L01) on filer.

  • Connect to Filer --> Courses
  • Connect to Filer and navigate to /Courses/CS353J_A_JP/<your username>/Private/.
  • Create a folder called Projects, inside that folder create the folder [your username]_[your partner's username]_L01
  • Copy your latest lab code inside [your username]_[your partner's username]_L01.

Submit a video and Check-in document on Google Classroom

Upload a 0.5-2 minute Documentation Video with narration.
  • Show that by blocking the IR Sensor the onboard LED turns on and off.
  • Say what you are doing while you are doing it.
Attach a Google Doc Check-in which includes:
  • Photo of circuit:
    • Clear photo of the circuit in which the wiring is clearly visible, wired correctly.
  • Video Description Paragraph:
    • 2-5 sentences describing what is happening in the video.
    • If complete: How does it work?
    • If incomplete: What is the current issue? Where are you stuck?
  • Project Idea:
    • 2-5 sentences describing an idea for a project that incorporates the IR detector and IR LED.
    • What is it?
    • How would you implement it?