Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "HID-Project.h"
- #define pageup 16
- #define pagedwn 10
- #define mouseleft A3
- #define mouseright A1
- //#define mousemiddle 4
- //#define mousescrolldown 5
- //#define mousescrollup 6
- #define mouseXp 14
- #define mouseXm A0
- #define mouseYp 15
- #define mouseYm A2
- //#define led 3
- int8_t Xval = 0 ;
- int8_t Yval = 0 ;
- int8_t scrollval = 0;
- bool pageuppressed = 0 ;
- bool pagedwnpressed = 0 ;
- void setup() {
- //Serial.begin(9600);
- //Serial.println("hello");
- // pinMode(led, OUTPUT);
- // analogWrite(led, 0);
- pinMode(pageup, INPUT_PULLUP);
- pinMode(pagedwn, INPUT_PULLUP);
- pinMode(mouseleft, INPUT_PULLUP);
- pinMode(mouseright, INPUT_PULLUP);
- // pinMode(mousemiddle, INPUT_PULLUP);
- // pinMode(mousescrolldown, INPUT_PULLUP);
- // pinMode(mousescrollup, INPUT_PULLUP);
- pinMode(mouseXp, INPUT_PULLUP);
- pinMode(mouseXm, INPUT_PULLUP);
- pinMode(mouseYp, INPUT_PULLUP);
- pinMode(mouseYm, INPUT_PULLUP);
- Mouse.begin();
- Keyboard.begin();
- }
- void loop() {
- delay(20) ;
- bool isPageup = digitalRead(pageup) ;
- if(isPageup == LOW && pageuppressed == 0){
- //Serial.println("PAGE UP");
- Keyboard.press(KEY_PAGE_UP);
- pageuppressed = 1 ;
- }
- if (isPageup == HIGH && pageuppressed == 1) {
- Keyboard.release(KEY_PAGE_UP);
- pageuppressed = 0 ;
- }
- bool isPagedwn = digitalRead(pagedwn) ;
- if(isPagedwn == LOW && pagedwnpressed == 0){
- //Serial.println("PAGE DOWN");
- Keyboard.press(KEY_PAGE_DOWN);
- pagedwnpressed = 1 ;
- }
- if (isPagedwn == HIGH && pagedwnpressed == 1) {
- Keyboard.release(KEY_PAGE_DOWN);
- pagedwnpressed = 0 ;
- }
- if(digitalRead(mouseleft) == LOW){
- if(Mouse.isPressed(MOUSE_LEFT) == LOW){
- //Serial.println("MOUSE_LEFT");
- Mouse.press(MOUSE_LEFT);
- }
- } else if (Mouse.isPressed(MOUSE_LEFT)){
- Mouse.release(MOUSE_LEFT);
- }
- if(digitalRead(mouseright) == LOW){
- if(Mouse.isPressed(MOUSE_RIGHT) == LOW){
- //Serial.println("MOUSE_RIGHT");
- Mouse.press(MOUSE_RIGHT);
- }
- } else if (Mouse.isPressed(MOUSE_RIGHT)){
- Mouse.release(MOUSE_RIGHT);
- }
- // if(digitalRead(mousemiddle) == LOW){
- // if (Mouse.isPressed(MOUSE_MIDDLE) == LOW){
- // //Serial.println("MOUSE_MIDDLE");
- // Mouse.press(MOUSE_MIDDLE);
- // }
- // } else if (Mouse.isPressed(MOUSE_MIDDLE)){
- // Mouse.release(MOUSE_MIDDLE);
- // }
- scrollval = 0;
- // if(digitalRead(mousescrolldown) == LOW){
- // //Serial.println("mousescrolldown");
- // scrollval = -1;
- // }
- // if(digitalRead(mousescrollup) == LOW){
- // //Serial.println("mousescrollup");
- // scrollval = 1;
- // }
- if(digitalRead(mouseXp) == HIGH && digitalRead(mouseXm) == HIGH){
- Xval = 0 ;
- }
- if(digitalRead(mouseXp) == LOW){
- //Serial.println("mouseXp");
- Xval++ ;
- }
- if(digitalRead(mouseXm) == LOW){
- //Serial.println("mouseXm");
- Xval-- ;
- }
- if(digitalRead(mouseYp) == HIGH && digitalRead(mouseYm) == HIGH){
- Yval = 0 ;
- }
- if(digitalRead(mouseYp) == LOW){
- //Serial.println("mouseYp");
- Yval++ ;
- }
- if(digitalRead(mouseYm) == LOW){
- //Serial.println("mouseYm");
- Yval-- ;
- }
- if(scrollval != 0 || Xval != 0 || Yval != 0 ){
- Mouse.move(Xval, Yval, scrollval);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement