rucek / arduino-ps2-mouse

38 stars 10 forks source link

Small fix for non-AVR boards #3

Open Tuet opened 1 year ago

Tuet commented 1 year ago

I am running this library on an ESP32-S3. My mouse seems to work fine with operating at only 3.3V instead of 5V, so I don't need level shifters. However, it is important to activate the internal pull-up resistor in the MCU using the more modern way to get this library working. To do so, change this

void PS2Mouse::high(int pin) {
    pinMode(pin, INPUT);
    digitalWrite(pin, HIGH);
}

to

void PS2Mouse::high(int pin) {
    pinMode(pin, INPUT_PULLUP);
    digitalWrite(pin, HIGH);
}

This should be also backward-compatible to AVR boards, but needs a more recent Arduino version.