Advertisement
Guest User

Simulacrum Beta 2

a guest
Jul 21st, 2012
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. //A0 is Right Rotation.
  2. //A1 is Left Rotation.
  3. //A2 is Right Pressure.
  4. //A3 is Left Pressure.
  5.  
  6. int cur = 0;
  7. int dur = 0;
  8.  
  9. boolean LeftFoot = false;
  10. boolean RightFoot = false;
  11.  
  12. unsigned long walked = 0;
  13. void setup() {
  14.   cur = analogRead(A0);
  15.   dur = analogRead(A1);
  16.   Mouse.begin();
  17.   Keyboard.begin();
  18. }
  19.  
  20. void loop() {
  21.   if((millis()>walked+250)&&(walked!=0)){
  22.     Keyboard.release('w');
  23.     walked = 0;
  24.   }
  25.   if((!LeftFoot)&&(analogRead(A3)>=500)){
  26.     LeftFoot = true;
  27.   }
  28.   if((!RightFoot)&&(analogRead(A2)>=500)){
  29.     RightFoot = true;
  30.   }
  31.   if((LeftFoot)&&(analogRead(A3)<500)){
  32.     walked = millis();
  33.     Keyboard.press('w');
  34.     LeftFoot = false;
  35.   }
  36.   if((RightFoot)&&(analogRead(A2)<500)){
  37.     walked = millis();
  38.     Keyboard.press('w');
  39.     RightFoot = false;
  40.   }
  41.   if(!((analogRead(A2)>500)&&(analogRead(A3)>500))){
  42.     if (abs(cur-analogRead(A0))>1){
  43.       if((RightFoot)&&(!LeftFoot)) {
  44.         Mouse.move((cur-analogRead(A0))*-4,0);
  45.       }
  46.       cur = analogRead(A0);
  47.     }
  48.     else if (abs(dur-analogRead(A1))>1){
  49.       if((LeftFoot)&&(!RightFoot)){
  50.         Mouse.move((dur-analogRead(A1))*-4,0);
  51.       }
  52.       dur = analogRead(A1);
  53.     }
  54.   }
  55.   delay(1);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement