Skip to content

Mikro.jsexperimental

TypeScript for microcontrollers

Modern JavaScript, type safety and instant refresh on real hardware.

Mikro.js logo

Your first program

Blinky: the "Hello, World!" of tiny devices.

ts
import {
digitalWrite
,
pinMode
} from 'mikrojs/pin'
import {
sleep
} from 'mikrojs/sleep'
// Replace with your board's LED pin if different const
LED_PIN
= 15
pinMode
(
LED_PIN
, 'OUTPUT').
orPanic
('Failed to set pin mode')
while (true) {
digitalWrite
(
LED_PIN
, 1)
await
sleep
(500)
digitalWrite
(
LED_PIN
, 0)
await
sleep
(500)
}

Get it running:

sh
npm create mikrojs -- my-blinky --template blinky
cd my-blinky
npm install
npx mikro dev
sh
pnpm create mikrojs my-blinky --template blinky
cd my-blinky
pnpm install
pnpm mikro dev
sh
yarn create mikrojs my-blinky --template blinky
cd my-blinky
yarn install
yarn mikro dev
sh
bun create mikrojs my-blinky --template blinky
cd my-blinky
bun install
bunx mikro dev

Learn more