print("Hello, LDR!")
print('Date: 30/11/2023')
print('Created by Muhei')
#Import libraries
from machine import Pin, ADC
from utime import sleep
#Declare Pin
LDR_pin = ADC (Pin(13, Pin.IN))
#Main Program
while True:
analogue_value_LDR = LDR_pin.read() #Analogue guna 'value', Digital guna 'read' klau convert guna 'ADC' (Analogue to Digital Converter)
print(analogue_value_LDR)
sleep(3)
voltage_of_light_intensity = analogue_value_LDR / 4096 * 5;
print('The voltage recorded based on the light intensity is', voltage_of_light_intensity, 'V')
print('\n')
if voltage_of_light_intensity <=2.5:
led.off()
elif 4 < voltage_of_light_intensity < 2.5:
led1.on()
led2.on()
led3.on()
led4.on()
else:
led1.on()
led2.on()
led3.on()
led4.on()
led5.on()