from machine import Pin, ADC
import utime
"""
Challenges
########################################################################################################################
Challenge 1 - Set Up Code with Joystick - Try both print Statements
Challenge 2 - Set up the wiring and code so that each led will light up as Joystick is moved
Challenge 3 - Leave the LED Lights (or matrix) and add a Servo that will work with the left, center and right positions -
Challenge 4 - Add a third servo that will toglle form up and down position when joystick is pressed - Imagine a robot with a scoop:)
Challenge 5 - Wow us =:)
#########################################################################################################################
"""
xAxis = ADC(Pin(27))
yAxis = ADC(Pin(26))
button = Pin(16,Pin.IN, Pin.PULL_UP)
while True:
xValue = xAxis.read_u16()
yValue = yAxis.read_u16()
buttonValue = button.value()
xStatus = "middle"
yStatus = "middle"
buttonStatus = "not pressed"
if xValue <= 600:
xStatus = "left"
elif xValue >= 60000:
xStatus = "right"
if yValue <= 600:
yStatus = "up"
elif yValue >= 60000:
yStatus = "down"
if buttonValue == 0:
buttonStatus = "pressed"
print("X: " + xStatus + ", Y: " + yStatus + " -- button " + buttonStatus)
##print("X: " + str(xValue) + ", Y: " + str(yValue) + " -- button " + str(buttonValue))
utime.sleep(0.1)
s