diff --git a/blink-pico-w/README.md b/blink-pico-w/README.md new file mode 100644 index 0000000..c9087d2 --- /dev/null +++ b/blink-pico-w/README.md @@ -0,0 +1,24 @@ +# Overview + +A blink example for Raspberry Pi Pico W. Contrary to the regular Pico, the LED on this board is connected to the WiFi chip (CYW43). + +# Code + +Turn on and off the on-board LED for every seconds. + +```js +const cyw43_arch = require('cyw43_arch'); +const led = 0 +let state = 1; + +setInterval(() => { + cyw43_arch.gpioPut(led, state); + state = (state + 1 ) % 2; // Toggle between 1 and 0 +}, 1000); +``` + +# See also + +- [pinMode()](https://kalumajs.org/docs/api/digital-io#pinmode) +- [digitalToggle()](https://kalumajs.org/docs/api/digital-io#digitaltoggle) +- [setInterval()](https://kalumajs.org/docs/api/timers#setinterval) diff --git a/blink-pico-w/index.js b/blink-pico-w/index.js new file mode 100644 index 0000000..dee7b8f --- /dev/null +++ b/blink-pico-w/index.js @@ -0,0 +1,8 @@ +const cyw43_arch = require('cyw43_arch'); +const led = 0 +let state = 1; + +setInterval(() => { + cyw43_arch.gpioPut(led, state); + state = (state + 1 ) % 2; // Toggle between 1 and 0 +}, 1000); diff --git a/blink-pico-w/package.json b/blink-pico-w/package.json new file mode 100644 index 0000000..6d47aed --- /dev/null +++ b/blink-pico-w/package.json @@ -0,0 +1,4 @@ +{ + "name": "blink-pico-w", + "description": "Blink the on-board LED on a Raspberry Pico W" +}