Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Private d1 As D1Pins
Private lPin, cPin, dPin As Pin
Private clockPin As Int = 12
Private dataPin As Int = 2
Private bitOrder As Boolean = False
Private tmr As Timer
Private Value As Byte = 0
Private count As Int = 0
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
lPin.Initialize(d1.D5, lPin.MODE_OUTPUT)
cPin.Initialize(d1.D6, cPin.MODE_OUTPUT)
dPin.Initialize(d1.D4, dPin.MODE_OUTPUT)
tmr.Initialize("tmr_Tick",1000)
tmr.Enabled = True
End Sub
Sub tmr_tick
If count = 8 Then
Value = 0x00
Else
Value = Bit.Set(Value,count)
End If
lPin.DigitalWrite(False)
RunNative("ShiftOut", Null)
lPin.DigitalWrite(True)
count = (count+1) Mod 9
End Sub
#If C
void ShiftOut(B4R::Object* o) {
shiftOut(b4r_main::_datapin, b4r_main::_clockpin,b4r_main::_bitorder, b4r_main::_value);
}
#End If