Parallax Penguin Manual page 21

Table of Contents

Advertisement

' Parallax Penguin Robot
' Penguin-IRTest.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
REmitter
CON
LEmitter
CON
IrInput
VAR
LeftIr
VAR
RightIr
VAR
DEBUG CLS
DEBUG "Infrared sensor status:", CR,
"Left:", CRSRXY, 15, 1,"Right:"
DO
GOSUB ReadIr
DEBUG CRSRXY, 6, 1, DEC LeftIr
DEBUG CRSRXY, 22, 1, DEC RightIr
PAUSE 150
LOOP
ReadIr:
FREQOUT LEmitter,1,6300
LeftIr = ~IrInput
FREQOUT REmitter,1,6300
RightIr = ~IrInput
RETURN
' Parallax Penguin Robot
' Penguin-7SegmentLEDTest-v1.3.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
' Rev A. boards use the OUTC port to control a 74LS47 BCD to 7-segment decoder
LEDDisplay
VAR
' Rev. B boards use a 74HC595 shift register to individually set and clear LEDs
LED_CLK
PIN
LED_DATA
PIN
LED_LATCH
PIN
ShiftData
VAR
Index
VAR
DIRC = %1111
DO
FOR Index = 0 TO 9
' For Rev. B PCBs, send data to the shift register
READ Index, ShiftData
SHIFTOUT LED_DATA, LED_CLK, LSBFIRST, [ShiftData]
LED_LATCH = 0
LED_LATCH = 1
' For Rev. A PCBs, set the 74LS47 in parallel through OUTC
LEDDisplay = Index
PAUSE 750
NEXT
LOOP
' Font for the Rev. B display
DATA $06, $CF, $A2, $C2, $4B, $52, $13 ,$CE, $02, $42
Copyright © Parallax Inc.
2
3
IN4
Bit
Bit
OUTC
8
9
10
Byte
Nib
Penguin Robot (#27313-27316)
' Prepare debug screen
' Update debug screen with
' status of IR sensors
' Modulate emitters at 38KHz
' and check for reflections
' The LED display mirrors OUTC
' LED's shift register clock pin
' LED's shift register data pin
' LED's shift register latch pin
' Set all used I/O pins as outputs
' Loop numbers 0-9 on the display
' Then create a falling edge
' To latch the data to the LEDs
' Wait 3/4 of a second
v1.4 2/16/2010 Page 21 of 23

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Penguin and is the answer not in the manual?

This manual is also suitable for:

27313273142731527316

Table of Contents