In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Rsadeika wrote: The following program works, I use this with my BS2IC when I get disallusioned with the SX. This is pretty straight foreward with pbasic. ****code ' {$STAMP BS2} ' {$PBASIC 2.5} IrDet PIN 2 'Activity board ThresholdStart CON 1000 ThresholdPulse CON 500 ThresholdEdge CON 300 One CON 1 ChUp CON 16 ChDn CON 17 VolUp CON 18 VolDn CON 19 Power CON 21 Mute CON 20 Last CON 59 IrPulse VAR Word remoteCode VAR Byte DO GOSUB GetCode IF (remoteCode > 0) THEN GOSUB processCode LOOP END processCode: ' DEBUG CLS, "Press Button ",CR ' IF (remoteCode = ChUp) THEN DEBUG "CH+ BUTTON" IF (remoteCode = ChUp) THEN GOSUB GoFore ' IF (remoteCode = ChDn) THEN DEBUG "CH- BUTTON" IF (remoteCode = ChDn) THEN GOSUB GoBack ' IF (remoteCode = VolDn) THEN DEBUG "VOL- BUTTON" IF (remoteCode = VolDn) THEN GOSUB GoForeLeft ' IF (remoteCode = VolUp) THEN DEBUG "VOL+ BUTTON" IF (remoteCode = VolUp) THEN GOSUB GoForeRight ' IF (remoteCode = Power) THEN DEBUG "Power BUTTON" IF (remoteCode = Power) THEN GOSUB RobotStop IF (remoteCode = Last) THEN GOSUB DriftRight IF (remoteCode = Mute) THEN GOSUB DriftLeft RETURN GetCode: remoteCode = 0 DO RCTIME IrDet, 1, IrPulse LOOP UNTIL irPulse > ThresholdStart PULSIN IrDet, 0, irPulse IF irPulse > ThresholdPulse THEN remoteCode.BIT0 = 1 RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge THEN remoteCode.BIT1 = 1 RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge THEN remoteCode.BIT2 = 1 RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge THEN remoteCode.BIT3 = 1 RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge THEN remoteCode.BIT4 = 1 RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge THEN remoteCode.BIT5 = 1 RCTIME IrDet, 0, irPulse IF irPulse > ThresholdEdge THEN remoteCode.BIT6 = 1 IF (remoteCode < 10) THEN remoteCode = remoteCode + 1 IF (remoteCode = 10) THEN remoteCode = 0 RETURN GoFore: HIGH 4 LOW 3 HIGH 5 LOW 6 RETURN GoBack: HIGH 3 LOW 4 HIGH 6 LOW 5 RETURN GoForeRight: HIGH 5 HIGH 3 LOW 6 PAUSE 1375 '1275 LOW 5 LOW 3 RETURN GoForeLeft: HIGH 4 HIGH 6 LOW 3 LOW 5 PAUSE 1575 LOW 4 LOW 6 RETURN RobotStop: LOW 3 LOW 4 LOW 5 LOW 6 RETURN DriftRight: LOW 4 PAUSE 300 GOSUB GoFore RETURN DriftLeft: LOW 5 PAUSE 300 GOSUB GoFore RETURN ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=97532#m97557 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)