Basically using the LDR and check the value.
given the condition as below
the picaxe read a light sensor measure (sensor 0) and show measures from 0 to 250, but if we suppose that 0 is 0% and 250 is 100% (presence of light)
LDR value 0 to 250 it will show 0 to 100%, also shows number of readings taken, it reads the LDR once per second.
Percentage = ldr * 100 / totalvalue
#picaxe 18x
symbol Percentage = b0
symbol ldr = b1
symbol Readings = b2
symbol TotalValue = 250
Readings=0
serout 7,n2400,(254,1)
pause 30
do
readadc 1, ldr
percentage = ldr * 100 / TotalValue
inc Readings
serout 7,n2400,(254,128,"Reading #",#Readings)
pause 30
serout 7,n2400,(254,192,"Light = ",#Percentage,"% ")
pause 1000
loop
No comments:
Post a Comment