print("Hello, ESP32!")
from machine import Pin
import time
ON = 1
OFF = 0
led1 = Pin(13, Pin.OUT);led2 = Pin(12, Pin.OUT);led3 = Pin(14, Pin.OUT)
key1 = Pin(15, Pin.IN, Pin.PULL_UP);key2 = Pin(2, Pin.IN,Pin.PULL_UP)
key3 = Pin(4,Pin.IN,Pin.PULL_UP)
count = 1
def callback_function1():
    led1.value(ON);led2.value(OFF);led3.value(OFF)
    print("LED1=ON LED2 OFF LED3=OFF")
    time.sleep(1)
def callback_function2():
    led1.value(OFF);led2.value(ON);led3.value(OFF)
    print("LED1=OFF LED2 ON LED3=OFF")
    time.sleep(1)
def callback_function3():
    led1.value(OFF);led2.value(OFF);led3.value(ON)
    print("LED1 = OFF LED2 OFF LED3 = ON")
    time.sleep(1)
while True:
   if (key1.value() == 0):
      count = count+1
   if(key2.value() == 0):
      count=count-1
   if(key3.value()==0):
      count =1
   if(count >=4):
      count = 3
   if(count <=0):
      count = 1
   if(count == 1):
      callback_function1()
   elif (count == 2):
      callback_function2()
   elif(count==3):
      callback_function3()
   else:
      led1.value(OFF);led2.value(OFF);led3.value(OFF)
      print("LED1=OFF LED2=OFF LED3=OFF")
      time.sleep(0.1)
      print(count)