Changeset 4af2eca in orbit


Ignore:
Timestamp:
11/14/12 18:24:04 (7 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
Children:
f323fb4
Parents:
1891404
Message:
  • Added support for "x" control command, allowing throttle percentage to be set directly (for example x000 for 0% and x100 for 100%)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • arduino/puzzlebox_orbit_Uno_V3/puzzlebox_orbit_Uno_V3.ino

    rf0fb814 r4af2eca  
    107107} 
    108108 
     109void setThrottle() { 
     110   
     111  char inByte=0; 
     112  int a=0; 
     113  int b=0; 
     114  int c=0; 
     115  int newThrottle=0; 
     116   
     117  while (Serial.available() == 0); 
     118  inByte = Serial.read() - '0'; 
     119  //Serial.println(inByte); 
     120  a = inByte; 
     121   
     122  while (Serial.available() == 0); 
     123  inByte = Serial.read() - '0'; 
     124  //Serial.println(inByte); 
     125  b = inByte; 
     126   
     127  while (Serial.available() == 0); 
     128  inByte = Serial.read() - '0'; 
     129  //Serial.println(inByte); 
     130  c = inByte; 
     131   
     132  newThrottle = (a * 100) + (b * 10) + c; 
     133   
     134  if (newThrottle < 0) 
     135    newThrottle=0; 
     136   
     137  if (newThrottle > 100) 
     138    newThrottle=100; 
     139     
     140  _throttle=newThrottle; 
     141   
     142  Serial.print("_throttle="); 
     143  Serial.println(int(_throttle)); 
     144   
     145} 
     146 
    109147void loop() 
    110148{int i; 
     
    123161      case '2':  _channel='B';  Serial.print("_throttle=B"); break; 
    124162      case '3':  _channel='C';  Serial.print("_throttle=C"); break; 
     163      case 'x':  setThrottle(); break; 
    125164    } 
    126165  } 
Note: See TracChangeset for help on using the changeset viewer.