#include <Mouse.h>
// Define button pins
const int button1Pin = 2; // Button 1 connected to pin D2
const int button2Pin = 3; // Button 2 connected to pin D3
void setup() {
// Initialize the serial communication
Serial.begin(9600); //Replace with Mouse.begin()
// Set button pins as input
pinMode(button1Pin, INPUT_PULLUP); // Use internal pull-up resistor for button 1
pinMode(button2Pin, INPUT_PULLUP); // Use internal pull-up resistor for button 2
}
void loop() {
// Read the state of the buttons
int button1State = digitalRead(button1Pin);
int button2State = digitalRead(button2Pin);
// Check if button 1 is pressed (LOW)
if (button1State == LOW) {
Serial.write("UP"); //replace with Mouse.move(0,0,2)
delay(150);
}
// Check if button 2 is pressed (LOW)
if (button2State == LOW) {
Serial.write("DOWN"); //replace with Mouse.move(0,0,-2)
delay(150);
}
// Add a small delay to avoid bouncing
delay(50);
}