Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Battery Class #5

Open
theDataSmith opened this issue Dec 12, 2016 · 0 comments
Open

Create a Battery Class #5

theDataSmith opened this issue Dec 12, 2016 · 0 comments
Assignees

Comments

@theDataSmith
Copy link
Contributor

Create a Battery Class that reads the voltage of the battery and can tell when the battery crosses below a given threshold (BATTERY_VOLTAGE_MIN). It should have a function that returns true if the battery voltage is below the threshold, false otherwise. Because the voltage read by the pin might not be accurate, we need to wait until we have multiple readings, and only return true if:

  • A minimum number of readings have been recorded.
  • Those readings are all similar to each other.
  • The average of those readings is below a given threshold.

Therefore, the class should store a number of readings in a queue (BATTERY_N_READINGS), and return false if the queue isn't full. It could then first calculate the average value of the readings, and return false if any one reading differs from the average by more than (BATTERY_MAX_DISCREPANCY).

Needed Arduino functions:
pinMode()
analogRead()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants