Testing Code Tags
Publison
Posts: 12,366
[
CODE]' {$STAMP BS2}
' {$PBASIC 2.5}UDPin CON 8LRPIn CON 9LR VAR WordUD VAR WordDO HIGH LRPin PAUSE 2 RCTIME LRPin, 1, LR HIGH UDPin PAUSE 2 RCTIME UDPin, 1, UD DEBUG HOME, "UD = ", DEC UD, ", LR = ", DEC LR, CLREOL PAUSE 50 LOOP[/code]
[PHP]' {$STAMP BS2}' {$PBASIC 2.5}UDPin CON 8LRPIn CON 9LR VAR WordUD VAR WordDO HIGH LRPin PAUSE 2 RCTIME LRPin, 1, LR HIGH UDPin PAUSE 2 RCTIME UDPin, 1, UD DEBUG HOME, "UD = ", DEC UD, ", LR = ", DEC LR, CLREOL PAUSE 50 LOOP
[/PHP]
CODE]' {$STAMP BS2}
' {$PBASIC 2.5}UDPin CON 8LRPIn CON 9LR VAR WordUD VAR WordDO HIGH LRPin PAUSE 2 RCTIME LRPin, 1, LR HIGH UDPin PAUSE 2 RCTIME UDPin, 1, UD DEBUG HOME, "UD = ", DEC UD, ", LR = ", DEC LR, CLREOL PAUSE 50 LOOP[/code]
[PHP]' {$STAMP BS2}' {$PBASIC 2.5}UDPin CON 8LRPIn CON 9LR VAR WordUD VAR WordDO HIGH LRPin PAUSE 2 RCTIME LRPin, 1, LR HIGH UDPin PAUSE 2 RCTIME UDPin, 1, UD DEBUG HOME, "UD = ", DEC UD, ", LR = ", DEC LR, CLREOL PAUSE 50 LOOP
[/PHP]
{{ ************************************************ * Hoverfly 9-DOF Experimenter Board * * Author: Al Ducharme and Dan Burroughs * * * ************************************************ Revision History: V1.0 - original program }} CON _CLKMODE = XTAL1 + PLL8X _XINFREQ = 10_000_000 '10MHz crystal is used I2C_SCL = 20 'Sensors share the same I2C bus I2C_SDA = 21 LEDRedPin = 24 'Status LED pins LEDGreenPin = 25 LEDBluePin = 26 ServoCh0 = 15 'These were tradionally used for Servo Outputs ServoCh1 = 16 ServoCh2 = 17 ReceiverCh0 = 13 'These were tradionally used for Receiver Inputs ReceiverCh1 = 12 ReceiverCh2 = 18 OBJ Debug : "FullDuplexSerialPlus" Sensors : "SensorDriver" VAR PUB main Debug.start(31, 30, 0, 115200) waitcnt(clkfreq*2 + cnt) 'wait 2 seconds before starting so you can enable Com on debug terminal Debug.tx(Debug#CLS) ' Set LED pins dira[LEDRedPin] := 1 dira[LEDGreenPin] := 1 dira[LEDBluePin] := 1 ' Start the Sensor driver Sensors.StartSensorData(2, I2C_SCL, I2C_SDA, Sensors#ITG_DLPF_10HZ) repeat Debug.Str(String(Debug#CLS,Debug#HOME)) Debug.tx(Debug#TAB) Debug.tx(Debug#TAB) Debug.Str(String("X")) Debug.tx(Debug#TAB) Debug.Str(String("Y")) Debug.tx(Debug#TAB) Debug.Str(String("Z")) Debug.tx(Debug#TAB) Debug.tx(Debug#CR) Debug.Str(String(" ---------------------")) Debug.tx(Debug#CR) Debug.Str(String("ITG3200 Gyro: ",Debug#TAB)) Debug.dec(Sensors.GetGyroX) Debug.tx(Debug#TAB) Debug.dec(Sensors.GetGyroY) Debug.tx(Debug#TAB) Debug.dec(Sensors.GetGyroZ) Debug.tx(Debug#CR) Debug.Str(String("ADXL345 Accel: ",Debug#TAB)) Debug.dec(Sensors.GetAccX) Debug.tx(Debug#TAB) Debug.dec(Sensors.GetAccY) Debug.tx(Debug#TAB) Debug.dec(Sensors.GetAccZ) Debug.tx(Debug#CR) Debug.Str(String("HMC5883L Mag: ",Debug#TAB)) Debug.dec(Sensors.GetMagX) Debug.tx(Debug#TAB) Debug.dec(Sensors.GetMagY) Debug.tx(Debug#TAB) Debug.dec(Sensors.GetMagZ) Debug.tx(Debug#CR) GyroLED waitcnt(clkfreq/20 + cnt) '10Hz screen refresh PUB GyroLED | x,y,z ' This is just for fun to make some colors with gyro movement ' move the board around...its pretty groooovy ' LEDs should be off when not moving the board x := Sensors.GetGyroX y := Sensors.GetGyroY z := Sensors.GetGyroZ if x >= 500 outa[LEDRedPin] := 1 else outa[LEDRedPin] := 0 if y <= 500 outa[LEDGreenPin] := 1 else outa[LEDGreenPin] := 0 if z <= 500 outa[LEDBluePin] := 1 else outa[LEDBluePin] := 0 PUB DelayMS(dur) waitcnt(clkfreq/1_000*dur + cnt) 'Approximate delay PUB DelayUS(dur) waitcnt(clkfreq/1_000_000*dur + cnt) 'Approximate delay
' {$STAMP BS2}' {$PBASIC 2.5} UDPin CON 8 LRPIn CON 9 LR VAR Word UD VAR Word DO HIGH LRPin PAUSE 2 RCTIME LRPin, 1, LR HIGH UDPin PAUSE 2 RCTIME UDPin, 1, UD DEBUG HOME, "UD = ", DEC UD, ", LR = ", DEC LR, CLREOL PAUSE 50 LOOP