|
Forum Index : Microcontroller and PC projects : RP2040-zero controlling the LED
| Author | Message | ||||
| Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5188 |
Ordered in a RP2040-zero to play around with, and see its got a RGB LED on the board. How would I use this LED. I've read its pin16, but switching that high or low has no effect. I'm guessing its I2C or something like that? Glenn PS, sorry, using the Picomite 2040 firmware. Edited 2026-07-28 12:21 by Gizmo The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
| mozzie Guru Joined: 15/06/2020 Location: AustraliaPosts: 407 |
G'day Glenn, The LED on the RP2040-Zero is a WS2812 RGB on pin 16, the inbuilt WS2812 command should do the trick WS2812 o,gp16,1,&h0f0f0f Makes a good status indicator if nothing else. The red and green on the units here are reversed, its GRB instead of RGB Hope the flow bench is progressing well, looking forward to an update. Regards, Lyle. Edited 2026-07-28 12:50 by mozzie |
||||
| EDNEDN Guru Joined: 18/02/2023 Location: United StatesPosts: 303 |
If it is a WS2812, you might try this piece of code and see if it lights up. I wrote this code to locate the LED on an off market board so there is some extra fluff code to scan different GPIO's. But it found my LED on GPIO-41. Yours might be the same. If not, you can start expanding the search loop by changing the "for p=41 to 41" to have a bigger range of pins. And it does use the Bitbang ws2812 o, p, 2, dd%() command suggested up above. ------------------------------------------------------------ 'WS2812 color LED program ' ' The YD-RP2040 board needs the R58 solder pads bridged ' in order for the WS1280 LED to work. Otherwise it is ' disconnected. ' Dim c%(16), dd%(1), n$(16) c%(0) = RGB(BLACK) : n$(0) = "Black " c%(1) = RGB(BLUE) : n$(1) = "Blue " c%(2) = RGB(CYAN) : n$(2) = "Cyan " c%(3) = RGB(RED) : n$(3) = "Red " c%(4) = RGB(MAGENTA) : n$(4) = "Magenta " c%(5) = RGB(YELLOW) : n$(5) = "Yellow " c%(6) = RGB(WHITE) : n$(6) = "White " c%(7) = RGB(COBALT) : n$(7) = "Cobalt " c%(8) = RGB(MYRTLE) : n$(8) = "Myrtle " c%(9) = RGB(MIDGREEN) : n$(9) = "Mid-Green" c%(10) = RGB(GREEN) : n$(10) = "Green " c%(11) = RGB(CERULEAN): n$(11) = "Cerulean " c%(12) = RGB(RUST) : n$(12) = "Rust " c%(13) = RGB(FUCHSIA) : n$(13) = "Fuchsia " c%(14) = RGB(BROWN) : n$(14) = "Brown " c%(15) = RGB(LILAC) : n$(15) = "Lilac " print " Red Green Blue" for p=41 to 41 print "Doing pin "; p For i=1 To 15 dd%(0) = c%(i) Print i; If i<10 Then Print " "; Print " ";n$(i);" "; Prt_Bits(c%(i)) Bitbang ws2812 O, p, 2, dd%() Pause 150 'Do While Inkey$="" 'Loop dd%(0) = RGB(black) Bitbang ws2812 o, p, 2, dd%() Next i next_pin: next p dd%(0) = RGB(black) 'Bitbang ws2812 o, GP23, 2, dd%() Pause 1000 End Sub Prt_Bits(arg1) Local i, j, k%, b$ b$ = "" k% = arg1 For i=23 To 0 Step -1 If i = 15 or i = 7 Then b$=b$+" " j = 1 << i If k% And j Then b$ = b$ + "1" Else b$ = b$ + "0" EndIf Next i Print b$ End Sub Edited 2026-07-28 12:56 by EDNEDN |
||||
| Glen0 Senior Member Joined: 12/10/2014 Location: New ZealandPosts: 102 |
I use this: Device WS2812 O, GP16, 1, RGB(BLUE) |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |