'-------------------------------------------------------------------------------
Sub Main()

' This program reads a potentiometer connected to pin 13. The green LED
' is made to blink at a rate such that the period is proportional to the
' pot position.

    Dim N As Integer
    Dim PotPosition As Single  ' Ranges from 0.0 to 1.0.

    Const PotPin As Byte = 13

    Const GreenLEDpin As Byte = 26
    Const RedLEDpin As Byte = 25

    Const LEDon As Byte = 0
    Const LEDoff As Byte = 1

    Debug.Print
    Debug.Print "Analog input example"
    Debug.Print

    Do
        ' Read nondimensional pot position.
        Call GetAdc(PotPin, PotPosition)

        ' LED blink period ranges from about 0.0 to 0.2 seconds.
        Call PutPin(GreenLEDpin, LEDon)
        Call Delay(PotPosition * 0.1)

        Call Putpin(GreenLEDpin, LEDoff)
        Call Delay(PotPosition * 0.1)
    Loop

End Sub
'-------------------------------------------------------------------------------
