Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Multithread Problem 3 blinking LED's

Best Answer liqdfire, 20 March 2014 - 02:56 AM

See if this is any better, I already put my logic analyzer away. 

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus

Module Module1

    Dim led1 As New OutputPort(Pins.GPIO_PIN_D0, False)
    Dim led2 As New OutputPort(Pins.GPIO_PIN_D1, False)
    Dim led3 As New OutputPort(Pins.GPIO_PIN_D2, False)
    Dim led4 As New OutputPort(Pins.GPIO_PIN_D3, False)

    Private _thread1Wait As AutoResetEvent
    Private _thread2Wait As AutoResetEvent
    Private _thread3Wait As AutoResetEvent

    Private _threadX As Thread
    Private _threadY As Thread
    Private _threadZ As Thread

    Sub Main()

        _thread1Wait = New AutoResetEvent(False)
        _thread2Wait = New AutoResetEvent(False)
        _thread3Wait = New AutoResetEvent(False)

        _threadX = New Thread(AddressOf led1t)
        _threadY = New Thread(AddressOf led2t)
        _threadZ = New Thread(AddressOf led3t)



        System.Threading.WaitHandle.WaitAll(New System.Threading.AutoResetEvent() {_thread1Wait, _thread2Wait, _thread3Wait})

        Thread.Sleep(Timeout.Infinite) ' Call this here or your program will exit..
    End Sub

    Sub led1t()

        Dim x As Integer = 0

        While x < 30
            x += 1
            Debug.Print("Led1 Blink Count = " & x.ToString)
        End While

    End Sub

    Sub led2t()

        Dim y As Integer = 0

        While y < 15
            y += 1
            Debug.Print("Led2 Blink Count = " & y.ToString)
        End While

    End Sub

    Sub led3t()

        Dim z As Integer = 0

        While z < 55
            z += 1
            Debug.Print("Led3 Blink Count = " & z.ToString)
        End While

    End Sub

End Module

Go to the full post

  • Please log in to reply
20 replies to this topic

#21 twinnaz


    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationBrampton, Ontario

Posted 20 March 2014 - 03:17 AM

Thanks once again

Netduino Plus 2

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.