Advertisement
Guest User

Untitled

a guest
May 13th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Put these into the Loop function
  2.  
  3. //Vibrate on breaking
  4. breakingVibrator(throttle);
  5.  
  6. //Alert user on connection loss
  7. connectionAlert(); 
  8.  
  9. //Functions
  10.  
  11. void connectionAlert()
  12. {
  13.   if(connected == false && triggerActive())
  14.   {
  15.   analogWrite( 6 , 255 );
  16.   delay(75);            
  17.  
  18.   analogWrite( 6 , 0 );    
  19.   delay(10);            
  20.   }
  21.  
  22. }
  23.  
  24. void breakingVibrator(int power)
  25. {
  26.   int v;
  27.   int minimumTreshold = 35;
  28.   v = map(power, 0, 512, 255, 30);
  29.  
  30.   if (v > minimumTreshold && ratioRpmSpeed * returnData.rpm > 1)
  31.   {
  32.     analogWrite( 6 , constrain(v, 0, 255));  
  33.   }
  34.   else
  35.   {
  36.     analogWrite( 6 , 0);
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement