![]() # Initial states for the buttons are all False LEDs = array.array("I", ) # Create array containing all the ZIP LEDs - "I" at start to indicate 32-bit number, then all 0sīuttonR = machine.Pin(13,, _DOWN) # Setup an input button on GP13 with a human-readable nameīuttonG = machine.Pin(14,, _DOWN) # Setup an input button on GP14 with a human-readable nameīuttonB = machine.Pin(15,, _DOWN) # Setup an input button on GP15 with a human-readable name ZIPStick.active(1) # Start the state machine, ready to receive data ZIPStick = StateMachine(0, ZIPLEDOutput, freq=8000000, sideset_base=machine.Pin(16)) # Create the state machine on GP16 # Setup a PIO state machine to drive the ZIP out_shiftdir=PIO.SHIFT_LEFT, autopull=True, pull_thresh=24) NumLEDs = 5 # Set the number of ZIP LEDs (5 on a ZIP Stick) '''Ĭontrol a ZIP Stick (addressable RGB LEDs)įrom rp2 import PIO, StateMachine, asm_pio ![]() To open in Thonny, copy and past the code below directly into the Thonny editor. To observe how different colours are made from mixing red, green and blue light.Īll experiments are coded in MicroPython in Thonny.To use the state machine to control ZIP LEDs (addressable RGB LEDs).To learn how to use the Pico Programmable I/O (PIO) to create a state machine.The PIO cannot be programmed directly with MicroPython, but the code with the special instructions can be written inside the main MicroPython program. Importantly, the PIO operates independently of the main processor on the Pico, which means that timing critical processes, like controlling ZIP LEDs, are not affected by the main program running. A PIO is like a tiny processor which is able to run a small amount of code for a specific task. The communication protocol for the ZIP LEDs (the sequence of 0s and 1s which control the colour settings) requires more than simple PWM control, and this is where the Pico’s Programmable I/O (PIO) are very useful. They are individually addressable, which means each one in the chain can have unique colour settings, created by mixing the red, green and blue light together. ZIP LEDs are special LEDs which contain a processor and three separate LEDs (red, green and blue) in one package. This experiment makes use of the ZIP Stick. Pico Inventor's Kit Exp' 10 - Controlling ZIP LEDs ![]() The experiments in these resources are written in the Thonny Editor using MicroPython. The Pico can be programmed in several languages. The Pico has 28 general purpose IO pins (GPIO), and 3 of these can also be used as Analogue inputs. ![]() These are like mini processors, and can help the Pico complete more complex tasks than it would otherwise be able to do. The RP2040 on the Pico uses 2 ARM processor cores, and also has 4 programmable IO controllers (PIO). The Raspberry Pi Pico is a compact microcontroller based on the RP2040 processor - Raspberry Pi’s first in-house designed silicon. This resource provides additional help and is not meant to replace the documentation that ships with the kit. Included in this resource are code downloads, a description of the experiment and also a video walk-through. Experiment 10 from the Inventors Kit for Raspberry Pi Pico, in which we controlling ZIP LEDs with code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |