?? 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 + -