Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //A0 is Right Rotation.
- //A1 is Left Rotation.
- //A2 is Right Pressure.
- //A3 is Left Pressure.
- int cur = 0;
- int dur = 0;
- boolean LeftFoot = false;
- boolean RightFoot = false;
- unsigned long walked = 0;
- void setup() {
- cur = analogRead(A0);
- dur = analogRead(A1);
- Mouse.begin();
- Keyboard.begin();
- }
- void loop() {
- if((millis()>walked+250)&&(walked!=0)){
- Keyboard.release('w');
- walked = 0;
- }
- if((!LeftFoot)&&(analogRead(A3)>=500)){
- LeftFoot = true;
- }
- if((!RightFoot)&&(analogRead(A2)>=500)){
- RightFoot = true;
- }
- if((LeftFoot)&&(analogRead(A3)<500)){
- walked = millis();
- Keyboard.press('w');
- LeftFoot = false;
- }
- if((RightFoot)&&(analogRead(A2)<500)){
- walked = millis();
- Keyboard.press('w');
- RightFoot = false;
- }
- if(!((analogRead(A2)>500)&&(analogRead(A3)>500))){
- if (abs(cur-analogRead(A0))>1){
- if((RightFoot)&&(!LeftFoot)) {
- Mouse.move((cur-analogRead(A0))*-4,0);
- }
- cur = analogRead(A0);
- }
- else if (abs(dur-analogRead(A1))>1){
- if((LeftFoot)&&(!RightFoot)){
- Mouse.move((dur-analogRead(A1))*-4,0);
- }
- dur = analogRead(A1);
- }
- }
- delay(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement