from machine import Pin
from utime import sleep
print("Let's guess the number!")
print("Date: 22/11/2023")
print("Created by m4trep")
print("\nThis program will ask you to guess a correct number\n")
#obtain input from the user:
target = int(input("Enter your favourite number from 1 until 9999:"))
#Pin declaration
LED_merah = Pin(13,Pin.OUT) #(GPIO pin no, IN or OUT)
LED_hijau = Pin(27,Pin.OUT)
while True:
print("\n===INSTRUCTION TO YOUR FRIEND===\n")
value = int(input("Guess my favourite number from 1 until 9999:"))
if value > target:
print("\nWRONG!", value, "is high/too high")
LED_merah.on()
elif int(value) < target:
print("\nWRONG!", value, "is low/too low")
LED_merah.on()
else:
print("\nPerfect! Kudos!")
LED_hijau.on()
LED_merah.off()
break