2026年9月19日土曜日

php 単体でうごかす

 Webサーバーを一切含めず「PHPコマンド(CLI)単体」だけを再度インストールし直す ということでよろしいでしょうか?それであれば、以下のコマンドを順に実行してください。1. パッケージリストの更新bashsudo apt update
コードは注意してご使用ください。2. PHP(CLI)単体のみをインストール余計なWebサーバー系パッケージを連動させず、PHPの実行環境だけをピンポイントで導入します。bashsudo apt install --no-install-recommends php-cli php-common -y
コードは注意してご使用ください。3. インストールの確認bashphp -v
コードは注意してご使用ください。この後、PHPの動作テストを行いますか?それとも、特定の拡張モジュール(mbstringやcurlなど)が必要、あるいはComposer(パッケージ管理ツール)の導入に進みますか?これはアンインストもできますかはい、こちらもapt purge コマンドを使うことで完全にアンインストールできます。手順は先ほどと同様に、設定ファイルごと綺麗に削除します。1. PHP(単体)の完全削除bashsudo apt purge php-cli php-common -y
コードは注意してご使用ください。2. 残った不要な設定やライブラリの自動削除bashsudo apt autoremove --purge -y
コードは注意してご使用ください。3. 削除の確認「そのようなファイルやディレクトリはありません」または「command not found」と表示されれば削除完了です。bashphp -v
コードは注意してご使用ください。もしPHPの代わりに別のプログラミング言語(Python、Node.js、Go言語など)を試してみたい場合や、Dockerなどの仮想環境でPHPを動かしたい場合は、いつでも手順をご案内しますので教えてください!

php built-in server使いたいPHPのビルトイン(組み込み)サーバーは、特別な設定なしでコマンド1つで起動できる開発用の簡易Webサーバーです。起動の手順ターミナル(コマンドプロンプト)を開きます。公開したいファイル(ドキュメントルート)があるディレクトリに移動します。次のコマンドを実行します。bashphp -S localhost:8000
コードは注意してご使用ください。ブラウザで http://localhost:8000 にアクセスします。主なオプションドキュメントルートを指定する (-t)公開フォルダを分ける場合は -t オプションを使います。bashphp -S localhost:8000 -t public
コードは注意してご使用ください。サーバーを終了するターミナルで Ctrl + C を押します。詳しい仕様や機能については、PHP公式マニュアルのビルトインウェブサーバー を確認してください。もしよければ、表示させたいプロジェクトの構成(フォルダの場所など)を教えていただければ、具体的なコマンドをご案内します。PHPPHP: ビルトインウェブサーバー - Manualビルトインウェブサーバーでは、次のような機能を使用することができます。 * **ドキュメントルートの指定** `-t` ...QiitaPHPビルトインウェブサーバーで簡易Webサーバを立てる #PHP - QiitaPHP にはビルトインウェブサーバーがあり、コマンドを使って簡易Webサーバーを立てることができます。ローカル環境でHT...Read the DocsPHP ビルトインサーバーの利用 - Read the DocsPHP ビルトインサーバーの利用¶. PHP5.4.0 以降では、PHP の組み込みの Web サーバーを開発用に使うこ...すべて表示他のマイコンからgetするには他のマイコン(M5Stack、ESP32、Arduino、Raspberry Pi Pico Wなど)から同じネットワーク内にあるPHPビルトインサーバーにGETリクエストを送る場合、「サーバー側の起動IPのアドレス」と「マイコン側のプログラム」の2つの設定が必要です。1. サーバー側の準備(重要)マイコンからアクセスさせる場合、localhost ではなく 0.0.0.0(またはPCのローカルIPアドレス)を指定してサーバーを起動する必要があります。localhost のままだと、PCの外部からの接続をすべて遮断してしまいます。ターミナルで以下のように起動してください:bashphp -S 0.0.0.0:8000
コードは注意してご使用ください。※これにより、同じWi-Fi(ルーター)に繋がっている他のデバイスからのアクセスを受け付けられるようになります。2. PCのローカルIPアドレスを確認するマイコンに指定するためのPCのIPアドレス(192.168.x.x など)を調べます。Windows (コマンドプロンプト): ipconfig を実行し「IPv4 アドレス」を確認。Mac / Linux (ターミナル): ifconfig または ip a を実行し en0 や wlan0 の inet を確認。3. マイコン側のコード例 (ESP32 / Arduino IDE)以下は、Wi-Fi機能を備えたマイコン(ESP32など)でPHPサーバーからデータをGETする典型的なコード例です。cpp#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = "あなたのWi-FiのSSID";
const char* password = "あなたのWi-Fiのパスワード";

// PCのローカルIPアドレスとポート、取得したいファイル名を指定
const char* serverUrl = "http://192.168.1"; 

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\nWi-Fi Connected!");
}

void loop() {
  if (WiFi.status() == WL_CONNECTED) {
    HTTPClient http;
    
    // GETリクエストを送信
    http.begin(serverUrl);
    int httpResponseCode = http.GET();
    
    if (httpResponseCode > 0) {
      String payload = http.getString();
      Serial.print("HTTP Response code: ");
      Serial.println(httpResponseCode);
      Serial.print("Response: ");
      Serial.println(payload); // PHPが返したテキストを表示
    } else {
      Serial.print("Error code: ");
      Serial.println(httpResponseCode);
    }
    http.end();
  }
  
  delay(10000); // 10秒ごとに実行
}

2026年9月14日月曜日

microlua and esplorer at ubuntu

lion d1 miniでビルトインLEDブリンク成功

led = nil

if my_timer then my_timer:unregister() my_timer = nil end

led = 4

gpio.mode(led, gpio.OUTPUT)

my_timer = tmr.create()

my_timer:register(1000, tmr.ALARM_AUTO, function()

    if gpio.read(led) == gpio.HIGH then

        gpio.write(led, gpio.LOW)

    else

        gpio.write(led, gpio.HIGH)

    end

end)

my_timer:start()

ーーーーーーーーーーーーーーーーーーーーーーーー

 https://nodemcu-build.com/ (オーダーメード) and use firware bin

1. APTを使用する方法(簡単)
Python環境を別途用意せず、システム管理として手軽にインストールしたい場合
bash
sudo apt update
sudo apt install esptool

esptool --port /dev/ie:ttyUSB0 --baud 460800 write_flash 0x00000 ie:firmware.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 /w by micopython(microdot as httpd,aqm0802,dht11)

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

pico-sdkはむずい、かわりにluaをesp8266でリベンジ、言語勉強はvlangをリベンジ

まあarduinolang,micropython,tinygoで困らんけどね PIC&Raspberry Piは休眠。。。。


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)

ーーーーーーーーーーーーーーーーーーーーーーーー

import machine

import time

import dht

# GPIO4番ピンにデータ線を接続した場合


sensor = dht.DHT11(machine.Pin(4))


while True:

    try:

        # センサーからデータを計測

        sensor.measure()


        # 温度(摂氏)と湿度(%)を取得

        temp = sensor.temperature()

        hum = sensor.humidity()


        print(f"温度: {temp} ℃, 湿度: {hum} %")


    except Exception as e:

        print("読み取りエラー:", e)


    # 2秒ごとに取得(DHT11は1秒に1回制限)

    time.sleep(2)



2026年9月11日金曜日

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

package main

import (

"machine"

"time"

)

func main() {

// 右ボタン(WIO_KEY_A)を入力ピン(プルアップ)として設定

buttonRight := machine.WIO_KEY_A // この書き方が正当

buttonRight.Configure(machine.PinConfig{Mode: machine.PinInputPullup})

// ブザーを出力ピンとして設定

for {

// ボタンは押されると「Low (false)」になります

if !buttonRight.Get() {

// ボタンが押されている間、簡易的にソフトウェアPWM(オン・オフ)で音を鳴らす

buzzer.High()

time.Sleep(1 * time.Millisecond)

buzzer.Low()

time.Sleep(1 * time.Millisecond)

} else {

// ボタンが離されているときはブザーを止める

buzzer.Low()

time.Sleep(10 * time.Millisecond) 

// チャタリング防止とCPU負荷軽減 この時間はinput getができないのでチャタ防止となる

}

}

}

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

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
コードは注意してご使用ください。