2024-11-01 21:51:43 +01:00

37 lines
651 B
C++

#include "GPIO.h"
// Konstruktor ( Quasi das Setup in einer Arduino.cpp - für jedes Objekt einzeln)
IO::IO(byte pin, bool input) {
this->GPIOPin = pin;
this->GPIOinput = input;
if (this->GPIOinput == false){
pinMode(this->GPIOPin, OUTPUT);
} else {
pinMode(this->GPIOPin, INPUT);
}
}
byte IO::SetHigh() {
digitalWrite(this->GPIOPin, HIGH);
if (this->GetState() == HIGH){
return 100;
} else {
return 200;
}
}
byte IO::SetLow() {
digitalWrite(this->GPIOPin, LOW);
if (this->GetState() == LOW){
return 101;
} else {
return 201;
}
}
byte IO::GetState() {
return digitalRead(this->GPIOPin);
}