28/03 11:39
nightwolf
ok, ho capito quello che vuoi dire, ma in visual basic come avverrebbe tutto ciò? ho fatto la conversione del codice e nell output c'è solo la divisione della stringa, non riceve niente da arduino. l ho tradotto così se è giusto
e poi dentro timer2
e nell output viene fuori
Bussola Vale: 50
Potenziometro Vale: 322
mentre tornando a l vecchio codice ho provato ad abbassare l intervall di timer2 a 500 e 250, e niente, stesso errore. ho prvato anche a portare il delay di arduino che prima era a 300 di portarlo a 500 come timer2, ed è lo stesso errore.
Shared esempio As String() = New String() {"-322.54;50-322.30", ";50-322.30;", "50-322.20;"}
e poi dentro timer2
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick Prova() End Sub Private Shared Sub Prova() Dim rn As Random = New Random() Dim lettura As String = esempio(rn.[Next](0, esempio.Length)) Dim ln As String() = lettura.Split("-"c) Dim val As String = ln.Where(Function(x) x.Contains(";")).FirstOrDefault() Dim val2 As String() = val.Split(";"c) Dim bussola As Integer = 0 Dim potenziometro As Integer = 0 If val2.Length = 2 Then If val2(0).Length > 1 AndAlso val2(1).Length > 1 Then Integer.TryParse(val2(0).Split("."c)(0), bussola) Integer.TryParse(val2(1), potenziometro) Console.WriteLine("Bussola Vale: " & bussola) Console.WriteLine("Potenziometro Vale:" & potenziometro) End If End If End Sub
e nell output viene fuori
Bussola Vale: 50
Potenziometro Vale: 322
mentre tornando a l vecchio codice ho provato ad abbassare l intervall di timer2 a 500 e 250, e niente, stesso errore. ho prvato anche a portare il delay di arduino che prima era a 300 di portarlo a 500 come timer2, ed è lo stesso errore.
aaa