2026年9月14日月曜日

microlua and esplorer at ubuntu

 https://nodemcu-build.com/ and use firware bin

---------------------------------------------

https://tomosoft.jp/design/?p=6810 :: esplorer-for-lua

--------------------------------------------------

can download the tool from ESPlorer to program ESP8266 and ESP32 chips with Lua on Ubuntu.

Installation Steps
  1. Install Java: ESPlorer is a Java application. Open your terminal and install Java using sudo apt update and sudo apt install default-jre.
  2. Download ESPlorer: Get the latest zip file from the official site.
  3. Extract the file: Unzip the downloaded archive to a folder of your choice.
  4. Run the program: Open a terminal in that folder and run java -jar ESPlorer.jar.

raspberry pi pico by micopython(aqm0802)

 http://jh7ubc.web.fc2.com/Raspberry_Pi/Raspberry_Pi_Pico/Pi_Pico_AQM0802A.htmlを参考に結線した やはりmpyは事例豊富、mmbasicとかkalumajsは英語サイトだけ

from machine import Pin, I2C

import utime

# I2C

i2c = I2C(

    0,

    freq=100000,

    scl=Pin(17),

    sda=Pin(16)

)


addr = 0x3e

buf = bytearray(2)


# コマンド送信

def write_cmd(cmd):

    buf[0] = 0x00

    buf[1] = cmd

    i2c.writeto(addr, buf)

# 文字送信

def write_char(char):

    buf[0] = 0x40

    buf[1] = char

    i2c.writeto(addr, buf)

# 文字列表示

def lcd_print(text):

    for c in text:

        write_char(ord(c))

# カーソル位置

def LCD_cursor(x, y):

    if y == 0:

        write_cmd(0x80 + x)

    if y == 1:

        write_cmd(0xc0 + x)


# LCDクリア

def LCD_clear():

    buf[0] = 0x00

    buf[1] = 0x01

    i2c.writeto(addr, buf)

    utime.sleep(0.002)


# LCDホーム

def LCD_home():

    buf[0] = 0x00

    buf[1] = 0x02

    i2c.writeto(addr, buf)

    utime.sleep(0.002)



# LCD初期化

def LCD_init():

    orders = [

        0x38,

        0x39,

        0x14,

        0x73,

        0x56,

        0x6c,

        0x38,

        0x0c,

        0x01

    ]


    utime.sleep(0.04)


    for order in orders:

        write_cmd(order)

        utime.sleep(0.002)


# =========================

# メイン

# =========================


LCD_init()


LCD_clear()

LCD_home()

lcd_print("JH7UBC")

num = 0

while True:

    LCD_cursor(0, 1)

    lcd_print(str(num))

    num = num + 1

    utime.sleep(1)

2026年9月11日金曜日

tinygo and witoterminal(p158,p159, p167 ,p185)

p158 code 

package main

import(

"machine"

"time"

)


func main(){

pwm := machine.TCC0

pwm.Configure(machine.PWMConfig{})

channelA,_:=pwm.Channel(machine.BUZZER_CTR)


notes:=[]uint64{440,494,523,585,659,698,783}

i:=0

for{

pwm.SetPeriod(1e9/notes[i])

pwm.Set(channelA,pwm.Top()/2)

time.Sleep(100*time.Millisecond)

pwm.Set(channelA,0)

i=(i+1)%len(notes)

}

}

p159

package main

import(
"machine"
"time"
"tinygo.org/x/drivers/tone"
)

func main(){
speaker,_ :=tone.New(machine.TCC0,machine.BUZZER_CTR)

notes:=[]tone.Note{tone.A5,tone.B5,tone.C6,tone.D6,tone.E6,tone.F6,tone.G6}
i:=0
for{
speaker.SetNote(notes[i])
time.Sleep(500*time.Millisecond)
i=(i+1)%len(notes)
}
}
--------------------------------p167-------------------------------
package main

import(
        "fmt"
"machine"
"time"
)

func main(){
   i2c := machine.I2C0
   i2c.Configure(machine.I2CConfig{
     SCL : machine.SCL0_PIN,
     SDA : machine.SDA0_PIN,
    })
    i2c.WriteRegister(0x18,0x20,[]byte{0x57})
    data := []byte{0,0,0,0,0,0}
    for {
      i2c.ReadRegister(0x18,0x28|0x80,data)
      x := readAcceleration(data[0],data[1])
      y := readAcceleration(data[2],data[3])
      z := readAcceleration(data[4],data[5])
      fmt.Printf("X:%6.2f Y:%6.2f Z:%6.2f\r\n",x,y,z)
      time.Sleep(100*time.Millisecond)
    }
}

func readAcceleration(l,h byte) float32{
  a := uint16(l) | uint16(h)<<8
  return float32(int16(a))/0x4000
}

  ------------p185----------------
https://sago35.github.io/SendReceiveでインタラクションできた
package main

import(
        "machine"
"machine/usb/midi"
"time"
)

func main(){
led:=machine.LCD_BACKLIGHT
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
m := midi.New()
m.SetHandler(func(b []byte){
  led.Toggle()
})
time.Sleep(1*time.Second)
for{
m.NoteOn(0,0,midi.C4,0x40)
time.Sleep(time.Millisecond * 1000)
m.NoteOff(0,0,midi.C4,0x40)
time.Sleep(time.Millisecond * 1000)
}
}
ーーーーーーーーーーーーーーーーーーーーーーーーー
https://www.onlinemusictools.com/kb/ で音がでた!

2026年9月10日木曜日

mmbasic pcのファイルをraspicoとやりとりしたい!!

 sudo picocom -b 115200 --omap delbs /dev/ttyACM0と,もう一つxterminalを立ち上げる

1. MMBasic 側で受信待機にする

MMBasic のプロンプトで以下のいずれかを実行します(保存先に応じて選んでください)。
  • プログラムメモリ(RAM)に直接読み込む場合:
    basic
    XMODEM RECEIVE
    
    コードは注意してご使用ください。
  • SDカードやフラッシュ内のファイルとして保存する場合:
    basic
    XMODEM RECEIVE "foo.bas"
    
    コードは注意してご使用ください。
2. Linux(PC)側から XMODEM で送信する
使用しているシリアル通信環境に合わせて、sx コマンドを使ってファイルを送信します。 [1, 2]
GNU screen を使用している場合:
シリアルセッション中に Ctrl+A を押した後、:exec !! sx foo.bas と入力するか、一度端末をバックグラウンドにして以下のようにリダイレクトします。 [1]
bash
sx foo.bas < /dev/ttyACM0 > /dev/ttyACM0
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
まずエディタからもどってRAM内容をsave "foo.bas"とする
成功しているかfilesで確認する
1. MMBasic(マイコン)側で送信コマンドを実行する
MMBasicのプロンプトで、送信したいファイル名を指定して XMODEM SEND(または省略形の XMODEM S)を実行します。 [1, 2]
  • SDカードやフラッシュ内のファイルを送信する場合:
    basic
    XMODEM SEND "foo.bas"
    
    コードは注意してご使用ください。
  • 現在メモリ(RAM)にあるプログラムをそのまま送信する場合:
    basic
    XMODEM SEND
    
    コードは注意してご使用ください。
コマンドを実行すると、マイコンはPC側からの受信開始合図(NAK文字など)を待つ状態(待機状態)になります。 [1, 2]
2. PC(Linux)側で XMODEM 受信を実行する
マイコンが待機状態になったら、60秒以内にPC側で受信コマンドを実行してください。Linuxでは rx コマンド(XMODEM受信ツール)を使用します。 [1]
一般的なシリアルポート(例: /dev/ttyACM0)で直接やり取りする場合:
端末(ターミナル)を開き、以下のコマンドを実行してファイルを受け取ります。
bash
rx foo.bas < /dev/ttyACM0 > /dev/ttyACM0
コードは注意してご使用ください。