arduino-photometrics/lib/sensor/photoresistance_ohm_retrieval.h
2025-11-26 16:30:22 +01:00

27 lines
649 B
C++
Executable file

#ifndef PHOTORESISANCE_OHM_RETRIEVAL_H
#define PHOTORESISANCE_OHM_RETRIEVAL_H
#include <Arduino.h>
const float mega2560_max_current = 50e-3; // 50 mA
const float mega2560_max_vcc = 5.5;
const int32_t r_voltage_divider = 330e3;
// SensorOhm calculate the value of the photoresistor with the voltage divider circuits
class SensorOhm {
public:
SensorOhm(uint8_t pin_analog_read = A0, float vcc = mega2560_max_vcc, int32_t rFixed = r_voltage_divider, float current = mega2560_max_current);
void setup();
int32_t readResistance();
private:
uint8_t pin_analog_read;
float vcc;
int32_t rFixed;
float current;
};
#endif