In this video I show how to use both cores on the Raspberry Pi Pico W. We will explore an example using threading where we will operate 2 LED and a servo.
In this lesson we demonstrate how to create a custom library on the Raspberry Pi Pico W to control a servo. We create a servo class, and then show how to use it as a library in future programs.
In this lesson we show how to write modular code in micropython. We demonstrate this with a simple example of how to calculate parameters of interest for a given rectangle. For your convenience, the code developed in the video is presented below. Enjoy!
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
defrectSolve(len,wid):
#global area,perimeter,diagonal
area=rectArea(len,wid)
perimeter=rectPerimeter(len,wid)
diagonal=rectDiagonal(len,wid)
returnarea,perimeter,diagonal
defrectArea(len,wid):
area=len*wid
returnarea
defrectPerimeter(len,wid):
perimeter=2*len+2*wid
returnperimeter
defrectDiagonal(len,wid):
diag=(len**2+wid**2)**(1/2)
returndiag
whileTrue:
l=float(input("What is Length of your Rectangle? "))
w=float(input("what is the Width of your Rectuangle? "))
In this Video Lesson we show how to calibrate a joystick to report Angular Position. We do this using MicroPython on a Raspberry Pi Pico W. For your convenience, the code is included below.
In this lesson we show how to get intuitive calibrated results from a joystick, connected to a Raspberry Pi Pico W, using microPython. This lesson will make it easy to incorporate a joystick into Pico W projects.
For your convenience, the code we develop in the video above is included below.
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
importmachine
importtime
importmath
hPin=27
vPin=26
hJoy=machine.ADC(hPin)
vJoy=machine.ADC(vPin)
whileTrue:
hVal=hJoy.read_u16()
vVal=vJoy.read_u16()
hCal=int(-.00306*hVal+100.766)
vCal=int(.00306*vVal-100.766)
mag=math.sqrt(hCal**2+vCal**2)
ifmag<=4:
hCal=0
vCal=0
print(hCal,vCal)
time.sleep_ms(200)
Making The World a Better Place One High Tech Project at a Time. Enjoy!