高校化学の教材;分子と結晶模型の「ベンゼン屋」

高校化学の教材;分子と結晶模型の「ベンゼン屋」

PR

プロフィール

cyn1953

cyn1953

キーワードサーチ

▼キーワード検索

サイド自由欄

楽天プロフィールをフォローしていただくと
ブログの更新がすぐわかります

[問い合わせ] benzeneya☆yahoo.co.jp
☆→@

分子と人間 (SAライブラリー) [ ピーター・W.アトキンス ]
身近な分子たち 空気・植物・食物のもと

紙書籍版もあります



カレンダー

コメント新着

通りすがり@ Re:ラズベリーパイpicoでCO2測定(4)フリスクサイズのCO2モニター(05/07) シンプルなプログラムで、過去の計測結果…
cyn1953 @ Re:明けましておめでとうございます…2022年記事ランキング(01/01) あけましておめでとうございます。 いつも…
湯口 秀敏@ Re:明けましておめでとうございます…2022年記事ランキング(01/01) 素晴らしい、継続は力なり、ですね。
2021.04.25
XML
カテゴリ: コンピューター
先に、ラズパイpicoで気象観測ツールを作りました。
ラズベリーパイPICOで温度・湿度・気圧を…⑥データを保存する(①‐⑥) ​→2021/4/19ブログ
同じように、I2Cにレーザー測距センサーvl53l0x(Amazonで999円)をつないいで、ものさしを作りました。
写真上は気象観測ツール。写真下が「ものさし」です。

ケースは2mm厚のアクリル板で作り、気象観測ツールと同じサイズにしてあります。
表示はOLEDのSSD1306(128x64)です。
数値とバーグラフで表示して、50cmを超えると「unable over50cm」と表示されるようにしました。
測距にはvl53l0xという、レーザー測距センサーを使っています。





配線は以下です。I2Cはプルアップ抵抗が必要となっていますが、抵抗なしで作りました。
いまのところ、問題なさそうです。

以下、配線です。

以下、MicroPythonのコーディングです。
「動けばいいや」で作ったものですので、荒っぽさはご容赦ください。


(1)main.py ; PICO内のルートに入れてあります。

##############################################################

# SSD1306 OLED Display , vl53l0x I2C Tests with the Raspberry Pi Pico

# modeified 2021/ 4/12 by cyn

# original

# https://github.com/raspberrypi/pico-micropython-examples/tree/master/i2c/1306oled

################################################################ ##

#

from machine import Pin, I2C

import framebuf,sys,time,utime,machine

from ssd1306 import SSD1306_I2C

from vl53l0x import VL53L0X

pix_res_x  = 128 # SSD1306 horizontal resolution

pix_res_y = 32   # SSD1306 vertical resolution

 # start I2C on I2C0 (GPIO 0/1)

i2c_dev = I2C(0,scl=Pin(1),sda=Pin(0),freq=400000)

# get I2C address in hex format

i2c_addr = [hex(ii) for ii in i2c_dev.scan()]

 # oled controller

i2c = I2C(0,sda=Pin(0), scl=Pin(1), freq=400000)

#clearOLED

oled.fill(0)

oled = SSD1306_I2C(pix_res_x, pix_res_y, i2c_dev)

i2c = I2C(id=id, sda=sda, scl=scl)

# Create a VL53L0X object

tof = VL53L0X(i2c)

# Pre: 12 to 18 (initialized to 14 by default)

# Final: 8 to 14 (initialized to 10 by default)

# the measuting_timing_budget is a value in ms, the longer the budget, the more accurate the reading.

budget = tof.measurement_timing_budget_us

print("Budget was:", budget)

tof.set_measurement_timing_budget(40000)

# Sets the VCSEL (vertical cavity surface emitting laser) pulse period for the

# given period type (VL53L0X::VcselPeriodPreRange or VL53L0X::VcselPeriodFinalRange)

# to the given value (in PCLKs). Longer periods increase the potential range of the sensor.

# Valid values are (even numbers only):

# tof.set_Vcsel_pulse_period(tof.vcsel_period_type[0], 18)

tof.set_Vcsel_pulse_period(tof.vcsel_period_type[0], 12)

# tof.set_Vcsel_pulse_period(tof.vcsel_period_type[1], 14)

tof.set_Vcsel_pulse_period(tof.vcsel_period_type[1], 8)

#-------------------------------------------------------------------

while True:

# Start ranging

    distance = ( tof.ping() -10)/10

    oled.fill(0)

#can not measure over 50cm

    if distance > 50:

        oled.fill(0)

        oled.text("unable over50cm",0,10)

        oled.show()

    else:   

#oled write distance

oled.text(str(distance)+"cm",30,10)

#oled write bar graph

        for i in range(distance/5):

            oled.text("=",i*8,20)

    #oled show

        oled.show()

        utime.sleep(0.5)



 ①ssd1306.py githubから検索してとりました。
  https://github.com/raspberrypi/pico-micropython-examples/tree/master/i2c/1306oled
 ②vl5310.py githubから検索してとりました。
  https://github.com/kevinmcaleer/vl53lx0/blob/master/vl53l0x.py

絶対値の測定精度はよくありません。
 distance = ( tof.ping() -10)/10
でー10(10mm)の補正を入れてありますが、それでも数mmの誤差があります。





お気に入りの記事を「いいね!」で応援しよう

最終更新日  2021.04.25 15:10:56
コメント(0) | コメントを書く


【毎日開催】
15記事にいいね!で1ポイント
10秒滞在
いいね! -- / --
おめでとうございます!
ミッションを達成しました。
※「ポイントを獲得する」ボタンを押すと広告が表示されます。
x

© Rakuten Group, Inc.
X
Mobilize your Site
スマートフォン版を閲覧 | PC版を閲覧
Share by: