Skip to content

Instantly share code, notes, and snippets.

Avatar

Toshihiko Arai araemon

View GitHub Profile
View index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<title>HTTP Live Streaming Test</title>
</head>
<body>
<h1>HTTP Live Streaming Test</h1>
<video width="640"
height="360"
src="stream.m3u8"
View server.py
from http.server import HTTPServer, SimpleHTTPRequestHandler
import os
import ipget # $ sudo pip3 install ipget==0.0.3
os.chdir("./www")
a = ipget.ipget()
ip, bit = a.ipaddr("eth0").split('/')
port = 5555
@araemon
araemon / MotorTest.py
Created Dec 2, 2020
ラズパイを使ってPWM制御でモータを制御するプログラム/モータドライバTA8428K/詳しくはこちら → https://101010.fun/iot/motor-driver-ta8428k.html
View MotorTest.py
# -*- coding: utf-8 -*-
from gpiozero import Motor
from time import sleep
### TA8428K モータドライバテスト ###
motor = Motor(14, 15) # GPIO14をIN1へ、GPIO15をIN2へ繋ぐ
motor.forward(0.3) # 0.3はモータの速度
sleep(2) # 2秒間正転し続ける
@araemon
araemon / SoundSensor.py
Created Nov 30, 2020
音センサーを作ってラズパイで音を感知させるプログラム。詳細はこちら → https://101010.fun/analog/diy-sound-sensor.html
View SoundSensor.py
# -*- coding: utf-8 -*-
import spidev
import time
import RPi.GPIO as GPIO
LED0 = 4 # GPIO番号
LED1 = 14
LED2 = 15
View led_switch_client.html
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js">
</script>
<script>
$(function () {
var ws = new WebSocket("ws://192.168.100.136:5555/");
$('#btn').on('click', function () {
View led_switch_sever.py
# -*- coding: utf-8 -*-
import RPi.GPIO as GPIO
from time import sleep
from websocket_server import WebsocketServer
LED = 11
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED, GPIO.OUT)
@araemon
araemon / blink_led_5_times_rpi_gpio.py
Created Nov 24, 2020
ラズパイでLEDを5回点滅させるプログラム(RPI.GPIO) -> https://101010.fun/iot/raspberry-pi-webbrowser-remote.html
View blink_led_5_times_rpi_gpio.py
@araemon
araemon / bmx055.py
Created Nov 22, 2020
BOSCHのBMX055を使ってラズパイでジャイロと加速度の値を読み取るPythonプログラム -> https://101010.fun/iot/raspberry-pi-gyro-bmx055.html
View bmx055.py
# -*- coding: utf-8 -*-
import smbus
import time
ACCL_ADDR = 0x19
GYRO_ADDR = 0x69
bus = smbus.SMBus(1)
@araemon
araemon / ScrapingSiteTitle.py
Created Nov 21, 2020
Pythonでサイトタイトルを抽出(スクレイピング)するプログラム/https://101010.fun/programming/python-beautifulsoup-googlerank.html
View ScrapingSiteTitle.py
import urllib.request
from bs4 import BeautifulSoup
url = "https://101010.fun/posts/world-ios-android-share-2020.html"
req = urllib.request.Request(url)
with urllib.request.urlopen(req) as res:
html = res.read()
@araemon
araemon / OpenpyxlWriteRows.py
Created Oct 28, 2020
openpyxlを使って、PythonからExcelファイルのデータを書き込む >>> https://101010.fun/programming/python-openpyxl-excel.html
View OpenpyxlWriteRows.py
def write():
wb = openpyxl.Workbook()
ws = wb.create_sheet(title='Hello')
list = ['hoge', 'huga', 'pico']
for i, data in enumerate(list):
row = i + 1
c = ws.cell(row=row, column=1)
c.value = data