📄 ex24 - 74hc165.bs2
字号:
' {$STAMP BS2}
' ==============================================================================
'
' File...... Ex24 - 74HC165.BS2
' Purpose... Input expansion with 74HC165
' Author.... Parallax
' E-mail.... stamptech@parallaxinc.com
' Started...
' Updated... 01 MAY 2002
'
'
' ==============================================================================
' ------------------------------------------------------------------------------
' Program Description
' ------------------------------------------------------------------------------
' This program shows how to read eight inputs with just three Stamp pins using
' a 74HC165 shift register.
' ------------------------------------------------------------------------------
' I/O Definitions
' ------------------------------------------------------------------------------
Clock CON 0 ' shift clock (74x165.2)
DataIn CON 3 ' shift data (74x165.7)
Load CON 4 ' input load (74x165.1)
' ------------------------------------------------------------------------------
' Variables
' ------------------------------------------------------------------------------
switches VAR Byte ' inputs switches
' ------------------------------------------------------------------------------
' Initialization
' ------------------------------------------------------------------------------
Initialize:
HIGH Load ' make output; initialize to 1
' ------------------------------------------------------------------------------
' Program Code
' ------------------------------------------------------------------------------
Main:
GOSUB Read_165 ' read 8-pos dip switch
DEBUG Home, "Switches = ", BIN8 switches, CR ' display binary mode
PAUSE 100
GOTO Main ' do it again
' ------------------------------------------------------------------------------
' Subroutines
' ------------------------------------------------------------------------------
Read_165:
PULSOUT Load, 5 ' grab the switch inputs
SHIFTIN DataIn, Clock, MSBPre, [switches] ' shift them in
RETURN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -