2026年5月2日土曜日

Kalumajs LED問題(picoOKだが。。。)/tinygo(picowOKなおUNOR3ok

picowの場合ビルトインledは特殊なコードが必要(ドキュメントよめ)

以下はpico/picow両方でうごく

pinMode(15, OUTPUT); // Set the pin 1 to output mode.

digitalWrite(15, HIGH); // Set the pin 1 to HIGH.

// Toggle the LED.

const { LED } = require('led');

const led = new LED(28); // LED connected to pin 0.

led.on();

delay(1000); // wait for 1sec

led.off();

delay(1000); // wait for 1sec

led.toggle(); // on

delay(1000); // wait for 1sec

led.toggle(); // off

ーーーーーーーーtinygoならPICOW OKーーーーーーーーーーーーーーーーーーー

tinygo flash -target=pico-w main.go うまくいかんときはpicowをブートモードでやる!

package main

import (

"machine"

"time"

)

func main() {

led := machine.GPIO28

led.Configure(machine.PinConfig{Mode: machine.PinOutput})

for {

led.High() // ON

time.Sleep(1 * time.Second)

led.Low() // OFF

time.Sleep(1 * time.Second)

}

}

ーーーーーーーtinygoならuno r4 OKーー

tinygo target=arduino main.gで

package main

import (

"machine"

"time"

)

func main() {

led := machine.LED

led.Configure(machine.PinConfig{Mode: machine.PinOutput})

for {

led.Low()

time.Sleep(time.Millisecond * 900)

led.High()

time.Sleep(time.Millisecond * 500)

}

}

0 件のコメント:

コメントを投稿