RoboidControl-cpp/Arduino/Things/DigitalInput.cpp

23 lines
575 B
C++

#include "DigitalInput.h"
#include <Arduino.h>
namespace RoboidControl {
namespace Arduino {
DigitalInput::DigitalInput(Participant* participant, unsigned char pin)
: TouchSensor(participant) {
this->pin = pin;
pinMode(pin, INPUT);
}
void DigitalInput::Update(unsigned long currentTimeMs, bool recursive) {
this->touchedSomething = digitalRead(pin) == LOW;
// std::cout << "DigitalINput pin " << (int)this->pin << ": " <<
// this->touchedSomething << "\n";
Thing::Update(currentTimeMs, recursive);
}
} // namespace Arduino
} // namespace RoboidControl