Skip to content

Commit c12a00c

Browse files
committed
Added voltage sensor.
1 parent e9c3f66 commit c12a00c

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/LEADS.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "Controller.h"
22
#include "Device.h"
3-
#include "WheelSpeedSensor.h"
4-
#include "Utils.h"
53
#include "PredefinedTags.h"
4+
#include "Utils.h"
5+
#include "VoltageSensor.h"
6+
#include "WheelSpeedSensor.h"

src/VoltageSensor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "VoltageSensor.h"
2+
3+
VoltageSensor::VoltageSensor(int *const pins) : Device<float>(pins) {}
4+
5+
void VoltageSensor::initialize() { pinMode(_pins[0], INPUT); }
6+
7+
float VoltageSensor::read() { return ((float) analogRead(_pins[0]) / 4.092) % 100 / 10; }

src/VoltageSensor.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef VOLTAGESENSOR_H
2+
#define VOLTAGESENSOR_H
3+
4+
5+
#include "Device.h"
6+
7+
class VoltageSensor : public Device<float> {
8+
public:
9+
WheelSpeedSensor(int *const pins);
10+
void initialize();
11+
float read();
12+
};
13+
14+
15+
#endif //VOLTAGESENSOR_H

0 commit comments

Comments
 (0)