mirror of
https://github.com/MOSH-Insa-Toulouse/5ISS-2024-2025-MARIN--MULLER-BOUJON.git
synced 2025-06-08 14:00:49 +02:00
27 lines
No EOL
634 B
C++
27 lines
No EOL
634 B
C++
#include "sensor.hpp"
|
|
#include <Arduino.h>
|
|
|
|
Sensor::Sensor()
|
|
{}
|
|
|
|
void Sensor::init(const uint8_t pin)
|
|
{
|
|
_pin = pin;
|
|
pinMode(_pin, INPUT);
|
|
digitalWrite(_pin, HIGH);
|
|
}
|
|
|
|
float Sensor::get_value()
|
|
{
|
|
/*
|
|
float sensor_volt;
|
|
float RS_gas; // Get value of RS in a GAS
|
|
float ratio; // Get ratio RS_GAS/RS_air
|
|
int sensorValue = analogRead(A0);
|
|
sensor_volt=(float)sensorValue/1024*5.0;
|
|
RS_gas = (5.0-sensor_volt)/sensor_volt; // omit *RL
|
|
//-Replace the name "R0" with the value of R0 in the demo of First Test
|
|
ratio = RS_gas/R0; // ratio = RS/R0
|
|
*/
|
|
return ((analogRead(_pin))/1024*5.0);
|
|
} |