EasyManuals Logo

SunFounder ESP32 User Manual

Default Icon
771 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #441 background imageLoading...
Page #441 background image
SunFounder ESP32 Starter Kit
(continued from previous page)
# IR receiver configuration
pin_ir = Pin(14, Pin.IN)
# Initialize the guessing game variables
lower = 0
upper = 99
pointValue = int(urandom.uniform(lower, upper))
count = 0
# Initialize the LCD1602 display
lcd = LCD()
# Initialize a new random value for the game
def init_new_value():
global pointValue, upper, lower, count
pointValue = int(urandom.uniform(lower, upper))
print(pointValue)
upper = 99
lower = 0
count = 0
return False
# Display messages on the LCD based on the game state
def lcd_show(result):
global count
lcd.clear()
if result == True:
string = "GAME OVER!\n"
string += "Point is " + str(pointValue)
else:
string = "Enter number: " + str(count) + "\n"
string += str(lower) + " < Point < " + str(upper)
lcd.message(string)
return
# Process the entered number and update the game state
def number_processing():
global upper, count, lower
if count > pointValue:
if count < upper:
upper = count
elif count < pointValue:
if count > lower:
lower = count
elif count == pointValue:
return True
count = 0
return False
# Process the key inputs from the IR remote control
def process_key(key):
global count, lower, upper, pointValue, result
(continues on next page)
3.39. 6.7 Guess Number 435

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SunFounder ESP32 and is the answer not in the manual?

SunFounder ESP32 Specifications

General IconGeneral
BrandSunFounder
ModelESP32
CategoryController
LanguageEnglish