My Project
analog.cpp
Go to the documentation of this file.
1 // Copyright (c) 2023 Samuli Nyman
2 // SPDX-License-Identifier: MIT
3 
4 #include "analog.h"
5 
6 
7 float calculateVoltageDegree3(int input) {
8  float a = -1.907217e-11;
9  float b = 8.368612e-08;
10  float c = 7.081732e-04;
11  float d = 1.572375e-01;
12 
13  return a * pow(input, 3) + b * pow(input, 2) + c * input + d;
14 }
15 
16 float adcToVoltage(int value)
17 {
18  return calculateVoltageDegree3(value);
19 }
20 
21 float analogReadVoltage(int pin)
22 {
23  int value = analogRead(pin);
24  return adcToVoltage(value);
25 }
analogReadVoltage
float analogReadVoltage(int pin)
Definition: analog.cpp:21
analog.h
adcToVoltage
float adcToVoltage(int value)
Definition: analog.cpp:16
calculateVoltageDegree3
float calculateVoltageDegree3(int input)
Definition: analog.cpp:7