Create a new application
Prerequisites
To complete all the below steps you will need:
- Node.js installed on your local machine
- A Raspberry Pi Pico connected to via USB to your local machine
- The Pico-SDK-JS Engine installed on your Raspberry Pi Pico
- The Pico-SDK-JS CLI installed on your local machine
Step 1: Create a repo from this template
To create your own Pico-SDK-JS application using our custom template, start by creating a GitHub repo from our existing template by clicking the below button.
Create new Repository on Github
After creating the new repository, you will need to clone it to your local machine by running:
git clone <repository path>
Step 2: Install tooling for building
This project is built using Typescript and webpack, but this setup has been taken care of for you. Simply run the below command in your cloned directory to install all the tooling you’ll need to build this app.
npm install
Step 3: Build the app
This project is written in Typescript, which is a strongly typed programming language built upon JavaScript to provide better error detection and tooling. In order to convert this Typescript project to a JavaScript file that can be executed on your Raspberry Pi Pico, run the below command.
npm run build
Step 4: Deploy the JavaScript to your Raspberry Pi Pico using the Pico-SDK-JS CLI
To execute your script on your Raspberry Pi Pico, you’ll need to install the Pico-SDK-JS CLI and upload your script to your Raspberry Pi Pico running the Pico-SDK-JS Engine (see the links above for instructions).
After connecting the Pico-SDK-JS CLI to your Raspberry Pi Pico run the below command in REPL to write the file to your Pico’s flash.
.write index.js -p ./dist/index.js
Step 5: Run your JavaScript
After uploading your JavaScript to the Raspberry Pi Pico, run the script by running the below command in REPL to run the file saved to your Pico’s flash.
.run index.js