i try to split two numbers (93 to 9 and 3) and convert it to binary.
That works fine (Thx to NooM). On a 3 i become FalseFalseTrueTrue (When i test the code on a Console)
But it dont do the same with the led's, who are connected two 74HC595 Shift Register's.
To use the shift register's, i use the Toolbox.Netmf.Hardware.dll
Here a piece of my Code :S
[expander]
Dim state As String = "13:93" ' write your code here ' We got 4 74HC595's in a chain Dim IcChain As Ic74hc595 = New Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D9, 1) Dim IcChain2 As Ic74hc595 = New Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D8, 1) For Counter = 0 To IcChain.Pins.Length - 1 Thread.Sleep(50) IcChain.Pins(Counter).Write(False) Next ' Led loop back and forward Dim o As String() = state.Split(":") Dim s As String = o(0) Dim t As String = o(1) Dim z1 As String = s(0) Dim z2 As String = s(1) Dim z3 As String = t(0) Dim z4 As String = t(1) Dim y As Integer Dim z1b As [Byte] = z1 z1b = z1b Or 0 << 0 z1b = z1b Or 0 << 1 z1b = z1b Or 0 << 2 z1b = z1b Or 0 << 3 Dim z2b As [Byte] = z2 z2b = z2b Or 0 << 0 z2b = z2b Or 0 << 1 z2b = z2b Or 0 << 2 z2b = z2b Or 0 << 3 'IcChain: 00010000 Problem: 10000000 'IcChain2:00011000 Problem: 00010000 IcChain.Pins(3).Write(True) IcChain2.Pins(1).Write((z1b And (1 << 3)) > 0) IcChain2.Pins(2).Write((z1b And (1 << 2)) > 0) IcChain2.Pins(3).Write((z1b And (1 << 1)) > 0) IcChain2.Pins(4).Write((z1b And (1 << 0)) > 0) Thread.Sleep(5000) 'IcChain: 00000000 Problem: 10000000 - It dont turn off -.- 'IcChain2:00000000 IcChain.Pins(3).Write(False) IcChain2.Pins(1).Write(False) IcChain2.Pins(2).Write(False) IcChain2.Pins(3).Write(False) IcChain2.Pins(4).Write(False) Thread.Sleep(5000) 'IcChain: 00010000 Problem: 11000000 'IcChain2:01001000 Problem: 00011000 IcChain.Pins(3).Write(True) IcChain2.Pins(1).Write((z2b And (1 << 3)) > 0) IcChain2.Pins(2).Write((z2b And (1 << 2)) > 0) IcChain2.Pins(3).Write((z2b And (1 << 1)) > 0) IcChain2.Pins(4).Write((z2b And (1 << 0)) > 0) Thread.Sleep(5000) 'IcChain: 00000000 Problem: 10000000 It dont turn off again :( 'IcChain2:00000000 IcChain.Pins(3).Write(False) IcChain2.Pins(1).Write(False) IcChain2.Pins(2).Write(False) IcChain2.Pins(3).Write(False) IcChain2.Pins(4).Write(False) Thread.Sleep(60000)[/expander]
I cant see the fail in the code, when i try the demo code from the netmf.toolbox site, it works fine :S
mfg
gfc