Project 8: Sensor Calibration


Introduction

In this project you will calibrate the light sensor by reading and analyzing test input. 

Code Lab

Do code lab 6 and 7 to practice for this assignment.

Starter Code

#include <ArduinoSTL.h>

using namespace std; 

const int lightSensor = A0; 

void setup() {
  Serial.begin(9600);
}

// Insert getSamples(...) and sortSamples(...) here. 

void loop() {
  cout << "Enter how many samples to take for calibration." << endl;
  int sampleCount; 
  cin >> sampleCount; 

  // Get samples from the light sensor...
  vector<int> samples; 
  getSamples(samples); 

  // Sort the samples that were retrieved...
  sortSamples(samples);

  // Print the information about the samples...
  cout << "There are " << samples.size() << " samples." << endl;
  cout << "The minimum sample is: " << samples[0] << endl;
  cout << "The minimum sample is: " << samples[samples.size()-1] << endl;
  cout << "The median sample is: " << samples[samples.size()/2] << endl;
}

Specifications

  1. Start with a new sketch and save the sketch using the name calibrate. 
  2. Write the getSamples() and sortSamples() functions 
  3. In your loop() function:
    1. Ask the user for how many samples to take for calibration (the number must be two or greater)
  4. In your getSamples() function
    1. Take the requested number of samples (separated by 100ms) 
    2. Place the samples into a vector. 
    3. The vector should be the argument to getSamples() hint: this should be a reference argument 
  5. In your sortSamples() function
    1. Use Bubble Sort to sort the samples
  6. Once complete the following should be true:
    1. samples[0] is the lowest valued sample
    2. samples[samples.size()-1] is the  highest valued sample
    3. samples[samples.size()/2] is the median sample
  7. Verify that your sorting worked properly. 

Style Requirements

Remember to follow all the style rules from previous assignments, as well as the new rules we recently covered, including:

  1. File comment block
  2. Function naming conventions 
  3. Indentation in functions and placement of curly braces 
  4. Function comment blocks 
  5. Use named constants instead of magic numbers
  6. Proper use of spaces around operators 

Grading Criteria (20)

The instructor will evaluate your assignment using the following criteria. Thus you should check your assignment against these criteria to maximize your score.

Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive. Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

  • 17: Demonstrates mastery of the program
    • Applies concepts from the lessons appropriately
    • Meets all specifications
    • Runs as required with no abnormal error conditions
    • Generates correct output given correct input
    • Correct file name
  • 13: Has most of the functionality expected of the program
    • Demonstrates some techniques from the lesson
    • Attempts to meet all but one of the specifications
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 11: Has some of the functionality expected of the program
    • Demonstrates some techniques from the lesson
    • Meets at least 1/2 of the specifications
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 8: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications
    • Has a major error or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 2: Does not compile or wrong file turned in
  • 0: Not turned in or not original work

Project Coding Style

  • 3: All code is well-documented and follows the specified coding styles
  • 2: Code has a minor documentation error
  • 1: Code has multiple documentation errors
  • 0: No apparent attempt to follow documentation standards or write documentation comments

How to Submit

Upload all project files to Blackboard in the project folder that matches the name of this project. Include the following items for grading:

  1. Class exercises
    1. vector.ino
    2. swap.ino
  2. calibrate.ino

You must submit all the files needed to complete your assignment. Your assignment must work as submitted. Remember to test and double check your files before submitting them. If you make a mistake, you can resubmit up to the deadline, but must resubmit all your assignment files.

Comments