Use A Joystick With Your Raspberry Pi Pico! - Science Electronics Fun!
Use A Joystick With Your Raspberry Pi Pico! - Science Electronics Fun!
Home
PIC microcontrollers
The p18f45K20 Demo Board!
R232 Communication uPIC
PIC micro controller LCD project
PIC USB Programming
dsPIC33EP256GM710
u8051
TIL 311
Introduction to I2C with the C8051F410
I2C EEPROM Project with the C8051F410
Expand your mind, and I/O ports! MCP23017 IO Port Expander! Presto, Expando!
STM32 MCUs
STM32 — bare chip example (STM32F042F6)
Robotics
Endstops/Limit Switches
Checking the accuracy of a motor encoder
Lab set up
Workbench
PCBs
PLDs
Programming the XC9572XL: A tutorial
FPGAs/SoCs
Zynq 7000 SoC: Digilent CORA Z7
Programming Digilent Cora 7Z via JTAG Interface
Spartan 3A FPGA
Microblaze core on Breadboarded Spartan 3A [XC3S200A-4VQG100C]
Programming the Terasic DE10-Lite board (Altera FPGA) with Quartus
Lattice ICE40UP5K-SG48 from the bare chip!
A CPU Core for your WebFPGA!
Breadboarding a Spartan 7 series FPGA
Specialty Chips
MCP2221 – Add USB to your MCU!
Raspberry pi pico
Raspberry pi pico – Knight Rider LED effect
Use a joystick with your raspberry pi pico!
CONTROLLING GIKFUN DC MOTOR WITH RASPBERRY PI PICO
Rasperry Pi Pico – Operate Baomain Pneumatic Cylinder SC 32-200
Games
Make your own game of Brick-O-Blox (Tetris clone)
1 import machine
2 import utime
3 import ustruct
4 import sys
6
7 #PMOD2 Joystick
8 #4 pins
9
10 led_up = Pin(13, Pin.OUT)
14
15 led_up.value(0)
16 led_right.value(0)
17 led_down.value(0)
18 led_left.value(0)
19
20 cs = machine.Pin(17, machine.Pin.OUT
21
22 spi = machine.SPI(0,
23 baudrate= 10000,
24 bits = 8,
25 firstbit=machine.S
26 sck=machine.Pin(18
27 mosi=machine.Pin(1
28 miso=machine.Pin(1
29
30 def getPosition(spi, cs):
31 msg = bytearray()
32
33 msg.append(0xC0)
34 msg.append(0x00)
35 msg.append(0x00)
36 msg.append(0x00)
37 msg.append(0x00)
38
39 cs.value(0)
40 spi.write(msg)
41 cs.value(1)
42
43 utime.sleep_us(25)
44
45 cs.value(0)
46 spi.write(msg)
47 data = spi.read(5)
48 cs.value(1)
49
50 return data
51
52 while 1:
53
54 data = getPosition(spi, cs)
55 print (data)
56 print (data[0])
57 print (data[1])
58 if data[0] > 225:
59 print ('RIGHT')
60 led_right.value(1)
61 else:
62 led_right.value(0)
63
64 if data[0] < 50:
65 print ('LEFT')
66 led_left.value(1)
67 else:
68 led_left.value(0)
69
70 if data[1] > 225:
71 print ('DOWN')
72 led_down.value(1)
73 else:
74 led_down.value(0)
75
76 if data[1] < 55:
77 print ('UP')
78 led_up.value(1)
79 else:
80 led_up.value(0)
81
82 utime.sleep(0.05)
83