Buy from US | Buy from UK | Buy from DE | Buy from IT | Buy from FR | Buy from ES | ここでご購入を! |
BBC micro:bit board x 1
OSOYOO RGB module x 1
OSOYOO 4-pin PnP cable x 1
OSOYOO Plug&Play( PnP ) board for micro:bit x 1
Connect RGB module to OSOYOO PnP board with a 4-pin PnP cable , make sure the pin connections must be exactly same as following figure;
Step 0: Go to url: https://makecode.microbit.org, click New Project
Step 1. In the Toolbox, click on the LED category and then drag a led enable false block and drop it inside the on start block
Step 2. Click on the Pins category ,drag an analog write pin block and drop it below LED enable false block. set write pin# to P2,value to 1023 as following figure:
Step 3. Right click analog write pin block and use Duplicate method twice . You will get two duplicated blocks ,and place them just below the first analog write pin block( still inside the on start block).
Set the pin# in two new blocks to P1 and P0 as following figure.
Step 4. Click on the Pins category. Drag an analog write pin block and drop it inside the forever block ,and set the write value from 1023 to 0 as following figure.
Step 5. In the Toolbox, click on the Basic category , drop a pause(ms) block drop it below analog write pin block(still inside the forever block) .Set the pause (ms) to 1000 as following figure.
Step 6. Repeat duplicate method to make another five analog write pin blocks and three pause(ms) blocks . Set the pin# and to value exactly same as following figure.
Step 7. In the Toolbox, click on the Loops category, drag a repeat times do block and place it below the last analog write pin P2 to 1023 block(inside the forever block). Set repeat times to 1 as following figure.
Step 8. Click on the Loops category. Drag a for index from block and drop it inside the repeat times do block .
right click the red index oval and then select rename variable from drop-down menu to create “Val” as a new variable name, then click on the Ok button. replace the value to 513 as following figure.
Step 9. In the Toolbox, click on the Pins category. Drag an analog write pin block place it inside the for val from 0 to 513 block .
Step 10. Click on the Variables category and then click a Val block over , and then Drag and drop the Val block inside the analog write P0 to block as following figure.
Step 11. In the Toolbox, click on the Pins category again. Then click and drag the analog write pin block and drop it inside the for val from 0 to block .
Step 12. Click on the Math category and drag an 0-0 block and place it below analog write pin to Val block. Then set left value in 0-0 block to 1023 as below figure.
Step 13. Click on the Variables category , Drag and drop the Val block to replace 0 value in the 1023-0 block as following figure.
Step 14. Use duplicate method to make another analog write pin P1 to 1023-Val block , drop this new block below original analog write pin P1 to 1023-Val block . Then the new block set write pin# to p2 , replace 1023 with 512 as following figure.
Step 15: Click on the Basic category, drop a pause(ms) block and drop it below last analog write pin P2 to 512-Val block(inside the for val from ), set the ms value to 1 as following figure.
Step 16. Repeat Step 8 to 15 and make another for Val from 0 to 513 loop block,place this new loop block just below the old for Val from 0 to 513 loop block . Change the pin# P0 and P1 ,P2 value and “to” statement as per following figure.
Step 17: In the Toolbox, click on the Pins category. Drag the analog write pin to block and place it below made-in-Step-16 Loop block(still inside the forever block) .set write pin# to P2 as following figure.
Step 18. Use duplicate method to make another two analog write blocks . place them below analog write block made in Step 17. Then change the Pin to P1,P0 as following figure:
Step 19.Download this “.hex” file and save it to your MICROBIT disk Driver as following figure.
Below are the full Graphic programming code blocks we have done for you as reference:
>
eted the experiment? In this way, you can also do more colorful lighting experiments.
DownLoad Url osoyoo.com