@@ -24,7 +24,7 @@ pin_clk = Pin(5, Pin.OUT)
2424pin_data = Pin(4 , Pin.OUT )
2525
2626num_leds = 10
27- chain = p9813.P9813(pin_clk, pin_data, num_leds)
27+ chain = p9813.P9813(pin_clk, pin_data, num_leds, False )
2828
2929# set the first LED to red
3030chain[0 ] = (255 , 0 , 0 )
@@ -45,13 +45,13 @@ chain.reset()
4545
4646See [ p9813_examples.py] ( p9813_examples.py ) and [ examples] ( examples/ ) for more.
4747
48- ## Parts
48+ ### Parts
4949
5050* [ WeMos D1 Mini] ( https://www.aliexpress.com/store/product/D1-mini-Mini-NodeMcu-4M-bytes-Lua-WIFI-Internet-of-Things-development-board-based-ESP8266/1331105_32529101036.html ) $4.00 USD
5151* [ Grove - Chainable RGB LED] ( https://www.seeedstudio.com/Grove-Chainable-RGB-LED-p-850.html ) $3.90 USD
5252* [ Grove Male Jumper Cable] ( https://www.seeedstudio.com/Grove-4-pin-Male-Jumper-to-Grove-4-pin-Conversion-Cable-%285-PCs-per-Pack%29-p-1565.html ) $2.90 USD
5353
54- ## Connections
54+ ## # Connections
5555
5656WeMos D1 Mini | Grove Chainable RGB LED
5757------------- | -----------------------
@@ -69,13 +69,67 @@ DO | DI (white)
6969VCC | VCC (red)
7070GND | GND (black)
7171
72- ## Links
72+ ### Links
7373
7474* [ WeMos D1 Mini] ( https://wiki.wemos.cc/products:d1:d1_mini )
7575* [ micropython.org] ( http://micropython.org )
7676* [ Adafruit Ampy] ( https://learn.adafruit.com/micropython-basics-load-files-and-run-code/install-ampy )
7777* [ P9813 datasheet] ( https://raw.githubusercontent.com/SeeedDocument/Grove-Chainable_RGB_LED/master/res/P9813_datasheet.pdf )
7878
79+ ## Example for BBC micro: bit
80+
81+ ### Software Setup - mu
82+
83+ * Download and setup the [ mu editor] ( https://codewith.mu/ ) .
84+ * Copy the ` p9813.py ` file from this repository into your ` mu ` code directory (usually ``` USER_DIR/mu ``` )
85+ * Create a new file with the code below
86+ * Flash it to the micro: bit . ** This will fail, the mirco: bit will display an error message**
87+ * Go into the files section of mu and copy the ` p9813.py ` file over.
88+ * micro: bit will restart and it should work
89+
90+ ### Software Setup - micro: bit editor
91+
92+ * go to the [ micro: bit python editor] ( https://python.microbit.org/v/2.0 )
93+ * select ` Load/Save `
94+ * Unfold the * Project Files* at the bottom of the pop-up
95+ * Select * Add File* and select the ` p9813.py ` file from this repo
96+ * paste the sample code below
97+ * flash the mirco: bit
98+
99+ ### Example Script
100+
101+ ``` python
102+ from microbit import *
103+ from p9813 import P9813
104+
105+ pin_clk = pin14
106+ pin_data = pin0
107+
108+ num_leds = 2
109+ chain = P9813(pin_data, pin_clk, num_leds, True )
110+
111+ # set the first LED to red
112+ chain[0 ] = (255 , 0 , 0 )
113+
114+ # set the second LED to green
115+ chain[1 ] = (0 , 255 , 0 )
116+
117+ # write data to all LEDs
118+ chain.write()
119+ sleep(200 )
120+ # make all LEDs red
121+ chain.fill((255 ,0 ,0 ))
122+ chain.write()
123+ sleep(2000 )
124+ # turn off all LEDs
125+ chain.reset()
126+ ```
127+
128+ ### Parts:
129+ * [ micro: bit ] ( https://microbit.org/ )
130+ * [ mirco: bit groove shield] ( https://www.seeedstudio.com/Grove-Shield-for-micro-bit-v2-0.html )
131+ * [ Grove - Chainable RGB LED] ( https://www.seeedstudio.com/Grove-Chainable-RGB-LED-p-850.html )
132+
79133## License
80134
81135Licensed under the [ MIT License] ( http://opensource.org/licenses/MIT ) .
0 commit comments