Changeset 30bc659 in orbit


Ignore:
Timestamp:
11/15/12 10:09:04 (7 years ago)
Author:
AzureViolin <zhanghaotz@…>
Branches:
master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
Children:
08d64cc
Parents:
f0fb814
Message:

arduino code for UNO final

Files:
9 added
1 edited

Legend:

Unmodified
Added
Removed
  • arduino/puzzlebox_orbit_Uno_V3/puzzlebox_orbit_Uno_V3.ino

    rf0fb814 r30bc659  
    2020 
    2121//variables start with "_" means global variable  
    22 char _throttle=87; //32~127 
    23 char _pitch=31; //0~63 
    24 char _yaw=78; //16~127 
     22char _throttle=0; //32~127, default 0 
     23char _pitch=31; //0~63, default 31 
     24char _yaw=78; //16~127, default 78 
    2525char _channel='A'; 
    2626char _command; 
     
    8484  checkSum=(16-checkSum) & B1111;//16-sum is the formula of this helicopter 
    8585   
    86   mainCode= (mainCode << 5) | (checkSum << 1); //get the last 4 digit of CheckSum, use XOR (^) to flip bits 
     86  mainCode= (mainCode << 5) | (checkSum << 1); //get the last 4 digit of CheckSum 
    8787  
    8888  bitWrite(mainCode,0,1);  //finish code 
     
    113113    _command = Serial.read(); 
    114114    switch (_command) 
    115     { 
    116       case 'U':  _throttle+=5;  Serial.print("_throttle="); Serial.println(int(_throttle)); break; 
    117       case 'D':  _throttle-=5;  Serial.print("_throttle="); Serial.println(int(_throttle)); break; 
    118       case 'L':  _yaw+=5;  Serial.print("_yaw="); Serial.println(int(_yaw)); break; 
    119       case 'R':  _yaw-=5;  Serial.print("_yaw="); Serial.println(int(_yaw)); break; 
     115    {  
     116      case 'P': _throttle=85; Serial.print("_throttle="); Serial.println(int(_throttle)); break; 
     117      case 'O': _throttle=0; Serial.print("_throttle="); Serial.println(int(_throttle)); break; 
     118      case 'U':  _throttle+=1;  Serial.print("_throttle="); Serial.println(int(_throttle)); break; 
     119      case 'D':  _throttle-=1;  Serial.print("_throttle="); Serial.println(int(_throttle)); break; 
     120      case 'L':  _yaw+=15;  Serial.print("_yaw="); Serial.println(int(_yaw)); break; 
     121      case 'R':  _yaw-=15;  Serial.print("_yaw="); Serial.println(int(_yaw)); break; 
    120122      case 'F':  _pitch+=5;  Serial.print("_pitch="); Serial.println(int(_pitch)); break; 
    121123      case 'B':  _pitch-=5;  Serial.print("_pitch="); Serial.println(int(_pitch)); break; 
    122       case '1':  _channel='A';  Serial.print("_channel=A"); break; 
    123       case '2':  _channel='B';  Serial.print("_throttle=B"); break; 
    124       case '3':  _channel='C';  Serial.print("_throttle=C"); break; 
     124      case '1':  _channel='A';  Serial.println("_channel=A"); break; 
     125      case '2':  _channel='B';  Serial.println("_channel=B"); break; 
     126      case '3':  _channel='C';  Serial.println("_channel=C"); break; 
    125127    } 
    126128  } 
Note: See TracChangeset for help on using the changeset viewer.