![]() ![]() ![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DemonstrationParts:
Hookup:
BX-24 programming:
This program sends data out to the shift register and 'counts' in binary: 0000_0001, 0000_0010, 0000_0011, etc. Option Explicit ' The actual pin numbers that you use below, doesn't matter, ' just MAKE SURE that it is properly updated Dim SerialData as Byte 'serial in - pin#12 on BX, pin#14 on 74HC595 Dim Clk as Byte 'shift register clock - pin#10 on BX, pin#11 on 74HC595 Dim Latch as Byte 'storage register clock (latch) - pin#11 on BX, pin#12 on 74HC595 Dim NumberOfBits as Byte 'the number of bits that you are sending to the register Public Sub Main() SerialData = 12 Clk = 10 Latch = 11 NumberOf Bits = 8 ' create counter variable dim counterVar as byte call delay(0.5) ' start program with a half-second delay do ' loop for each 'binary' number for counterVar = 0 to 255 ' set the clock low. sync it with the clock of the bx call putPin(Clk, 0) ' set the latch low call putPin(Latch, 0) ' send the data out ' shiftOut(DataPin, ClockPin, NumberOfBits, Operand) ' in this case, we are send out the data of the 'binary number' call shiftOut(SerialData, Clk, NumberOfBits, counterVar) ' display the number that we are counting debug.print cStr(counterVar) ' delay, so that we can actually 'see' something call delay(0.3) ' set the latch high call putPin(Latch, 1) next loop end sub |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LCDs · Introduction to Physical Computing · Prof. Tom Igoe |