$25
CS 362 Lab 8
Learning Goal:
• Learn how to program with interrupts.
Lab: Due Wednesday 4/3/2019
Write a program for the Arduino that utilizes interrupts. Interrupts allow a section of Arduino
code to be called without writing code in the loop( ) function to explicitly check that code.
The lab is to have you use 2 buttons and the 16x2 LCD display. Each button is to trigger an
interrupt. The interrupts are to toggle between two states/messages displayed on the 16x2 LCD.
• When no button has been pressed your 16x2 display should say something like "We have
been waiting for X seconds", where X starts at the value 0 and is updated as time goes on.
This is State 0.
• When the first button is pressed, the display should display “Interrupt received! Press
button 2 to continue”. This is State 1.
• When the user presses the second button, the display goes back to displaying "We have
been waiting for X seconds", and restarts the time at 0 seconds. (I.E. go back to State 0.)
Information about how to tell the system to call your Interrupt Service Routine (ISR) can be
found at:
http://arduino.cc/en/Reference/attachInterrupt
Information about timer:
https://www.arduino.cc/en/Reference/Millis
Important note: You must use pin 2 and pin 3 for this lab. Those two pins are specifically set up
to work with interrupts.
To be considered completed “on time”, this Lab needs to be demonstrated by end of Lab on
Wednesday 4/3/2019. Your code must be submitted to Gradescope BEFORE you demo your
lab!
Late Policy
• Late Submission - Submitted and/or demonstrated later that week (before Friday 4/5/19
11:59pm) 25% Penalty
• Late submission – Submitted and/or demonstrated during the following week (before
Friday 4/12/19 11:59pm) 50% Penalty
What should I include with my .ino Code File?
As with any code file, it should be written in Good Coding Style: in a manner that will help other
people read and understand the intent, purpose, operation of the code. So your code must
include:
• Name the .ino file with your NetId and Lab Number
o I.E. something like: ptroy4Lab2.ino
• Header Comments (including the following)
o // FirstName LastName, UIN and NetID
CS 362 Lab 8 Spring 2019
o // Lab x - Title
o // Description - what is this code supposed to do?
o // Include any assumptions you may have made, what do you expect from the
hardware, pinouts, particular arduino versions, etc.
o // References - where did you find code snippets, ideas, inspirations? if no
references used say: "no references used"
• Code is well documented/formatted with comments, indentations, and
descriptive variable names
• Actual code - the functions in the cpp/ino file