Imports Emant
Module Module1

    Sub Main()
        Dim volt As Double
        Dim lux As Double
        Dim limit As Double
        Dim DAQ As Emant300 = New Emant300
        Dim s As Stat = New Stat
        If DAQ.Open Then
            Console.WriteLine("EMANT300 Found")
            Dim luxarray1(3) As Double
            Dim i As Integer = 0
            While i < 3
                volt = DAQ.ReadAnalog(Emant.Emant300.AIN.AIN0, Emant.Emant300.AIN.COM)
                lux = 1333 * volt
                luxarray1(i) = lux
                DAQ.Delay(100)
                System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
            End While
            limit = s.Average(luxarray1) * 0.8
            Dim luxarray(10) As Double
            Console.Write("Red LED will light up if Light Intensity in Lux is less than ")
            Console.WriteLine(CType(limit, Integer))
            i = 0
            While i < 10
                volt = DAQ.ReadAnalog(Emant.Emant300.AIN.AIN0, Emant.Emant300.AIN.COM)
                lux = 1333 * volt
                Console.WriteLine(CType(lux, Integer))
                DAQ.WriteDigitalBit(2, (lux > limit))
                luxarray(i) = lux
                DAQ.Delay(1000)
                System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
            End While
            Console.WriteLine("Max {0}", CType(s.Max(luxarray), Integer))
            Console.WriteLine("Min {0}", CType(s.Min(luxarray), Integer))
            Console.WriteLine("Average {0}", CType(s.Average(luxarray), Integer))
            DAQ.Close()
        Else
            Console.WriteLine("DAQ Module NOT Found, Please check connections")
        End If
        Console.WriteLine("Press any key to continue")
        Console.ReadLine()
    End Sub

End Module
