Advertisement
Guest User

Untitled

a guest
Feb 16th, 2012
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. if(mode == 8) {
  2.     //analogWrite(rtrigPinout, 255);
  3.     digitalWrite(rtrigPinout, HIGH);
  4.    
  5.     ltrigValue = analogRead(ltrigPin);
  6.     // if ltrigValue is more than half
  7.     if (ltrigValue < 655) {
  8.     knobValue = analogRead(knobPin); //get the delay setting from the knob
  9.     //lets change the 1/5 to 1/4 or 1/8
  10.         knobDiv = knobValue>>2;  //knobDiv = knobValue/4
  11.         digitalWrite(ltrigPinout, HIGH);
  12.         unsinged int i = 0x0;
  13.     delay(40);
  14.     for(i=0;i<=knobValue;i=i+knobDiv){//0,1/4,1/2,3/4,1 == 5 times
  15.             delay(knobValue);
  16.             ltrigValue = analogRead(ltrigPin);
  17.             //should define a threshold rather than chose < 1
  18.             //in the case there is some noise on the trigger line
  19.             //#define THRESH 10
  20.             if(analogRead(ltrigPin)){
  21.                 break;
  22.             }
  23.         }
  24.         digitalWrite(ltrigPinout,LOW);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement