ik ben met een project bezig wanneer ik een button indruk de servo gaat draaien nu doet hij dit niet en kan zo niet achter komen wat ik fout heb gedaan
type or pa#ifndef MY_BUTTON_H
#define MY_BUTTON_H
#include <Arduino.h>
class Button {
private:
byte _pin;
byte state;
byte lastReading;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;
public:
Button();
void init(byte pin);
void update();
byte getState();
bool isPressed();
};
#endifste code here
#include "Button.h"
Button::Button() {
lastReading = LOW;
}
void Button::init(byte pin) {
_pin = pin;
pinMode(_pin, INPUT_PULLUP);
update();
}
void Button::update() {
byte newReading = digitalRead(_pin);
if (newReading != lastReading) {
lastDebounceTime = millis();
}
if (millis() - lastDebounceTime > debounceDelay) {
state = newReading;
}
lastReading = newReading;
}
byte Button::getState() {
update();
return state;
}
bool Button::isPressed() {
return (getState() == HIGH);
}
void deuropen()
{
if (button1.isPressed())
{
myMotor.getDegree();
}
}