ex04 - ping pong.bs2

来自「proteus得一些经典例子」· BS2 代码 · 共 45 行

BS2
45
字号
' {$STAMP BS2}
' ==============================================================================
'
' File...... Ex04 - Ping Pong.BS2
' Purpose... Ping-Pong LED Display
' Author.... Parallax
' E-mail.... stamptech@parallaxinc.com
' Started...
' Updated... 01 MAY 2002
'
'
' ==============================================================================
' ------------------------------------------------------------------------------
' Program Description
' ------------------------------------------------------------------------------
' "Ping-Pongs" an LED (one of eight).
' ------------------------------------------------------------------------------
' I/O Definitions
' ------------------------------------------------------------------------------
LEDs VAR OutL ' LEDs on Pins 0 - 7
' ------------------------------------------------------------------------------
' Constants
' ------------------------------------------------------------------------------
DelayTime CON 100 ' delay time in milliseconds
' ------------------------------------------------------------------------------
' Initialization
' ------------------------------------------------------------------------------
Initialize:
DirL = %11111111 ' make all pins outputs
LEDs = %00000001 ' start with one LED on (pin 0)
' ------------------------------------------------------------------------------
' Program Code
' ------------------------------------------------------------------------------
Go_Forward:
PAUSE DelayTime ' show the LED
LEDs = LEDs << 1 ' shift lit LED to the left
IF (LEDs = %10000000) THEN Go_Reverse ' test for final position
GOTO Go_Forward ' continue in this direction
Go_Reverse:
PAUSE DelayTime ' show the LED
LEDs = LEDs >> 1 ' shift lit LED to the right
IF (LEDs = %00000001) THEN Go_Forward ' test for final position
GOTO Go_Reverse ' continue in this direction
END

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?