In this lesson I show how to practically implement an Infrared IR sensor into a Raspberry Pi Pico project. For your convenience, the code developed in the video is included below.
In this lesson we demonstrate using both cores on the Raspberry Pi Pico W. The program controls a servo from a push button. The servo is controlled on the second core by a thread, and the push button is monitored in the main program.
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? "))
a,p,d=rectSolve(l,w)
print("Your Rectangle Information: ")
print("Area: ",a)
print("Perimeter: ",p)
print("Diagonal: ",d)
print()
Making The World a Better Place One High Tech Project at a Time. Enjoy!
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok