MatrixMiniR4 1.1.5
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
MiniR4Digital.h
Go to the documentation of this file.
1
6#ifndef MiniR4Digital_H
7#define MiniR4Digital_H
8
13// #include "Sensors/MiniR4_Grove_TM1637.h"
14#include <Arduino.h>
15
26template<uint8_t PIN1, uint8_t PIN2> class MiniR4Digital
27{
28public:
30 {
31 _pin1 = PIN1;
32 _pin2 = PIN2;
33 }
34
43 bool getL(bool pullup = false)
44 {
45 if (pullup) {
46 pinMode(_pin1, INPUT_PULLUP);
47 } else {
48 pinMode(_pin1, INPUT);
49 }
50 return digitalRead(_pin1);
51 }
52
61 bool getR(bool pullup = false)
62 {
63 if (pullup) {
64 pinMode(_pin2, INPUT_PULLUP);
65 } else {
66 pinMode(_pin2, INPUT);
67 }
68 return digitalRead(_pin2);
69 }
70
78 void setL(bool level = HIGH)
79 {
80 pinMode(_pin1, OUTPUT);
81 digitalWrite(_pin1, level);
82 }
83
91 void setR(bool level = HIGH)
92 {
93 pinMode(_pin2, OUTPUT);
94 digitalWrite(_pin2, level);
95 }
96
102 void toggleL()
103 {
104 pinMode(_pin1, OUTPUT);
105 digitalWrite(_pin1, !digitalRead(_pin1));
106 }
107
113 void toggleR()
114 {
115 pinMode(_pin2, OUTPUT);
116 digitalWrite(_pin2, !digitalRead(_pin2));
117 }
118
119 MiniR4HC04<PIN1, PIN2> US; // MATRIX Ultrasonic sensor instance.
120 MiniR4DHT11<PIN1, PIN2> DHT11; // Grove DHT11 sensor instance.
121 MiniR4DS18B20<PIN1, PIN2> DS18B20; // Grove DS18B20 temperature sensor instance.
122 MiniR4_Grove_US<PIN1, PIN2> GroveUS; // Grove ultrasonic sensor(ranger) instance.
123 // MiniR4_Grove_TM1637<PIN1, PIN2> GroveTM1637; // Grove 7-segment display instance (TBD).
124
125 MiniR4DHT11<PIN2, PIN1> MXDHT; // MATRIX DHT11 temperature and humidity sensor instance.
126 MiniR4DS18B20<PIN2, PIN1> MXOnewireDT; // MATRIX DS18B20 temperature sensor instance.
127
128private:
129 uint8_t _pin1;
130 uint8_t _pin2;
131};
132
133#endif // MiniR4Digital_H
Header file for the DHT11 sensor interface library.
Lightweight library for working with 1-Wire Dallas DS18B20 thermometers.
A library for interfacing with the Grove Ultrasonic Ranger sensor.
Handling MiniR4.Dn HC-04 Ultrasonic functions.
A class for interfacing with Grove Ultrasonic Ranger.
A template class to interface with the DHT11 temperature & humidity sensor.
Template class for interfacing with DS18B20 temperature sensors.
Class for handling digital input and output operations.
bool getR(bool pullup=false)
Reads the state of the second pin.
MiniR4DHT11< PIN1, PIN2 > DHT11
bool getL(bool pullup=false)
Reads the state of the first pin.
MiniR4DS18B20< PIN1, PIN2 > DS18B20
void toggleR()
Toggles the state of the second pin.
MiniR4HC04< PIN1, PIN2 > US
MiniR4DS18B20< PIN2, PIN1 > MXOnewireDT
void setL(bool level=HIGH)
Sets the level of the first pin.
void setR(bool level=HIGH)
Sets the level of the second pin.
void toggleL()
Toggles the state of the first pin.
MiniR4DHT11< PIN2, PIN1 > MXDHT
MiniR4_Grove_US< PIN1, PIN2 > GroveUS
Class for controlling the HC-SR04 ultrasonic sensor.
Definition MiniR4HC04.h:22