This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf-8 | |
from smbus2 import SMBus | |
import time | |
import RPi.GPIO as GPIO | |
interrupted = False | |
GPIO.setwarnings(False) | |
import time | |
import board |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
country=JP | |
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev | |
update_config=1 | |
network={ | |
ssid="ネットワークのSSID" | |
psk="wifiネットワークのパスワード" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mac $ diskutil list | |
/dev/disk0 (internal): | |
#: TYPE NAME SIZE IDENTIFIER | |
0: GUID_partition_scheme 251.0 GB disk0 | |
1: …… | |
/dev/disk1 (synthesized): | |
#: TYPE NAME SIZE IDENTIFIER | |
0: APFS Container Scheme - +250.7 GB disk1 | |
1: …… |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <VL6180X.h> | |
#define SPEAKER 8 | |
VL6180X sensor; | |
void setup() | |
{ | |
Serial.begin(9600); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SparkFun_TB6612.h> | |
#define AIN1 2 | |
#define AIN2 4 | |
#define PWMA 5 | |
#define STBY 9 | |
const int offsetA = 1; | |
Motor motor1 = Motor(AIN1, AIN2, PWMA, offsetA, STBY); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ライブラリ | |
#include <Wire.h>//I2Cライブラリ | |
#include <VL6180X.h>//TOF距離センサーのライブラリ | |
#include <SparkFun_TB6612.h>//モータードライバのライブラリ | |
//センサー、サウンド関連 | |
#define SPEAKER 8//スピーカーを接続したピン | |
#define VOLUME_SWITCH 13//音量調整つまみのスイッチに接続する端子 | |
VL6180X sensor;//TOF距離センサーのオブジェクト | |
const int minFreq = 262;//最低の周波数 ド(C4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int motorSpeed = analogRead(MOTOR_SPEED);//速度調整つまみの値を取得 | |
if ( motorSpeed > 10 )//つまみの値が一定以上なら | |
{ | |
motorSpeed = map( motorSpeed, 10, 1023, 40, 255 );//つまみの値をスピードに変換 | |
motor1.drive( motorSpeed );//指定したスピードでモーターを回す | |
} else { | |
motor1. brake();//つまみの値が一定以下ならモーターを止める | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool volumeSwitchState = digitalRead(VOLUME_SWITCH);//音量つまみスイッチの値を取得 | |
if ( volumeSwitchState == 0 ) {//音量つまみスイッチがオンなら | |
tone(SPEAKER, frequency );//TOF距離センサーからの距離に応じた周波数の音を鳴らす | |
} else { | |
noTone(SPEAKER);//スイッチがオフなら音を止める | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float distance = sensor.readRangeSingleMillimeters();//TOF距離センサーの値を取得(単位:mm) | |
bool offsetButtonState = digitalRead(ORIGIN_BUTTON); //原点設定ボタンの状態を取得 | |
if ( offsetButtonState == 0 && prevButtonState == 1 )//原点設定ボタンが押されたら、 | |
{ | |
origin = distance;//originを現在のdistanceに変更 | |
} | |
prevButtonState = offsetButtonState;//prevButtonStateを更新 | |
float frequency = map(distance, origin, origin-heightRange, minFreq, maxFreq);//距離を周波数に変換 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SparkFun_TB6612.h> | |
#define AIN1 2 | |
#define AIN2 4 | |
#define PWMA 5 | |
#define STBY 9 | |
const int offsetA = 1; | |
Motor motor1 = Motor(AIN1, AIN2, PWMA, offsetA, STBY); |
NewerOlder