Skip to content

Instantly share code, notes, and snippets.

Avatar

Toshihiko Arai araemon

View GitHub Profile
@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
@araemon
araemon / OpenpyxlReadRows.py
Last active Oct 28, 2020
openpyxlを使って、PythonからExcelファイルのデータを読み込む >>> https://101010.fun/programming/python-openpyxl-excel.html
View OpenpyxlReadRows.py
items = {}
path = "items.xlsx"
wb = openpyxl.load_workbook(path)
ws = wb["alink"]
for row in ws.rows:
items[row[0].value] = {'Title': row[1].value, 'URL': row[2].value}
View billion_order.py
# -*- coding: utf-8 -*-
import sqlite3
from timer import Timer
def dbname(n):
return 'test_{n}.sqlite'.format(n=n)
View timer.py
import time
class Timer(object):
def __enter__(self):
self.start = time.time()
return self
def __exit__(self, *args):
self.end = time.time()
You can’t perform that action at this time.