Shop OBEX P1 Docs P2 Docs Learn Events
Air Hogs 4 channel IR controller — Parallax Forums

Air Hogs 4 channel IR controller

Eagle8587Eagle8587 Posts: 6
edited 2014-08-08 18:14 in BASIC Stamp
I wanted to find a new purpose for my old air hogs controller it was from the helix 360 it is a 4 channel IR remote with a light button.
now with the long IR code running servos directly is a bit choppy i would suggest using servo pals to drive servos since i currently dont have any i have not supplied a code for that what i have attached it the Stick desplay code. Each channel uses 5 bits and the light uses a single bit and the first 4 bits in the code i havent determined their function and i didnt dive past the light bit.

' {$STAMP BS2}' {$PBASIC 2.5}


' Air Hogs Helix 360 4 channel remote


irPulse   VAR     Word ' Stores pulse widths
VLS       VAR     Byte ' Stores Vertical Left Stick
HRS       VAR     Byte ' Stores Horizontal Right Stick
HLS       VAR     Byte ' Stores Horizontal Left Stick
VRS       VAR     Byte ' Stores Vertical Right Stick
light     VAR     Bit  ' Stores Light bit
RCU       VAR     Nib  ' Stores unknown pulses




DO                                   ' Main DO...LOOP
                                     '
  VLS         = 0                    '
  HRS         = 0                    '
  HLS         = 0                    '
  VRS         = 0                    '
  light       = 0                    '
  RCU = 0                            '
                                     '
  DO                                 ' Wait for end of resting state.
    RCTIME 9, 1, irPulse             '
  LOOP UNTIL irPulse > 1000          '
                                     '
  PULSIN 9, 0, irPulse               '-----------|
  IF irPulse > 400 THEN RCU.BIT0 = 1 '  unknown  |
  RCTIME 9, 0, irPulse               '           |
  IF irPulse > 400 THEN RCU.BIT1 = 1 '           |
  RCTIME 9, 0, irPulse               '           |
  IF irPulse > 400 THEN RCU.BIT2 = 1 '           |
  RCTIME 9, 0, irPulse               '           |
  IF irPulse > 400 THEN RCU.BIT3 = 1 '           |
                                     '           |
                                     '-----------|
  RCTIME 9, 0, irPulse               'Throttle   |
  IF irPulse > 400 THEN VLS.BIT4 = 1 '           |
  RCTIME 9, 0, irPulse               '           |
  IF irPulse > 400 THEN VLS.BIT3 = 1 '           |
  RCTIME 9, 0, irPulse               '           |
  IF irPulse > 400 THEN VLS.BIT2 = 1 '           |
  RCTIME 9, 0, irPulse               '           |
  IF irPulse > 400 THEN VLS.BIT1 = 1 '           |
  RCTIME 9, 0, irPulse               '           |
  IF irPulse > 400 THEN VLS.BIT0 = 1 '           |
                                     '           |
                                     '-----------------------|
  RCTIME 9, 0, irPulse               'horizontal right stick |
  IF irPulse > 400 THEN HRS.BIT4 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN HRS.BIT3 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN HRS.BIT2 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN HRS.BIT1 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN HRS.BIT0 = 1 '                       |
                                     '                       |
                                     '-----------------------|
  RCTIME 9, 0, irPulse               'horizontal left stick  |
  IF irPulse > 400 THEN HLS.BIT4 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN HLS.BIT3 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN HLS.BIT2 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN HLS.BIT1 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN HLS.BIT0 = 1 '                       |
                                     '                       |
                                     '                       |
  RCTIME 9, 0, irPulse               '-----------------------|
  IF irPulse > 400 THEN VRS.BIT4 = 1 ' right vertical stick  |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN VRS.BIT3 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN VRS.BIT2 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN VRS.BIT1 = 1 '                       |
  RCTIME 9, 0, irPulse               '                       |
  IF irPulse > 400 THEN VRS.BIT0 = 1 '                       |
                                     '-----------------------|
  RCTIME 9, 0, irPulse               ' Light button |
  IF irPulse > 400 THEN light = 1    '              |




 DEBUG CLS,? VLS,
       ? HRS,
       ? HLS,
       ? VRS,
       ? light,
       ? RCU, HOME
LOOP

any suggestions or ideas for my code would be greatly welcomed
I used a portion of code from the IR Remote AppKit Project Code it helped get me started with the heli IR remote
Sign In or Register to comment.