For Deliverable 3 (6.4% of final grade) all students will submit a library that controls the HC-SR04 proximity sensor that came with the Arduino Kit. Please watch the tutorial for using this sensor before doing the assignment.

Develop a "class HCSR04ProxSensor" featuring these methods:

HCSR04ProxSensor(int echoPin, int triggerPin);//constructor

float readSensor();//read sensor in cm

float getLastValue();//get previous reading to be able to determine whether an object approaches or retracts.

The above .zip file contains an Arduino sketch that runs the sensor. To run, it needs the library that you need to submit as part of this assignment. Make sure that your sensor setup uses the same trigger and echo pins as specified in the sketch.This needs to be submitted: Add appropriate .h and .cpp files to the folder making the above sketch work directly 'out of the folder' (i.e. without having to add a library to the IDE library folder. If this is a mystery, please, watch the 'Making libraries with the Arduino' tutorial). Then .zip the folder and upload it to Deliverable 3 on Canvas. The folder must have the name "HCSR04_<YourfirstnameLastname>". Make sure there are no spaces in the folder name. For grading we will unzip the submitted file and then open the .ino file in it with the Arduino IDE and then it must work.Before you upload, please make sure that the libraries really work with the provided sketch. If it does not you will get 0 pts. Start the Arduino IDE by directly clicking on the sketch in the folder that you want to submit, if this compiles and works everything should be o.k..

Grading:

If the sketch works 'out of the box' the grade will be 70 pts.

If the folder within the zip file is correctly named (see above) you can get 80 pts.

To get 100: make sure that:

each significant command line is commented

an introductory comment tells the reader who did it, when was it made, and what it is for

the code is well structured and readable, and

#ifndef statements to prevent repeat header compilation are present

Please note, that for this assignment everybody needs to write their own code, no copy/pasting/plagiarizing/downloading is tolerated. The purpose is to learn to write a class and make a library, i.e. please do it on your own.

Late submissions:

Up to one hour: 10 pts penalty.

Later than one hour: 20 pts penalty.

Submissions later than 24 hrs will not be accepted without valid excuse (doctor's note, accident report etc...).