Skip to content

Instantly share code, notes, and snippets.

@myy
myy / ECMtoServoSample.ino
Created October 14, 2012 11:47
コンデンサマイクから拾った音量が一定以上のときに,サーボモータを動かす
// コンデンサマイクから拾った音の大きさが一定以上であれば,サーボを動かす
// 2012/08/21 できた!でも,一定以上の音が鳴っている間はサーボの角度を維持するようにしたいなあ
#include <Servo.h>
Servo myservo; // Servo型の変数
int ecmPin = 0; // ECMは0ピンへ接続
//int state = 0; // サーボの状態.1のときは130度まで回転した状態.0のときは30度まで回転した状態
void setup()
@myy
myy / randomWord.rb
Created October 25, 2012 04:59
複数の形容詞が記述されているファイルを読み込み,そのうちの一語をランダムに表示する
# -*- encoding: utf-8 -*-
# 2012/10/25 作成
# 複数の形容詞が記述されているファイルを読み込み,
# そのうちの一語をランダムに表示する
# adjectives.txtを読み込む
f = IO.readlines("adjectives.txt")
# readlines: 指定されたファイルを全て読み込んで,各行を要素として持つ配列を返す
@myy
myy / countdown.html
Created November 4, 2012 04:42
残り日数のカウントダウン
<!DOCTYPE HTML>
<html lang="ja">
<head>
<meta charset="UTF-8"/>
<title>いろいろカウントダウン</title>
</head>
<body>
<h1>残り日数を計算できます</h1>
@myy
myy / myTimer.html
Created November 7, 2012 06:54
自分用のタイマー.http://www.pori2.net/js/timer/6.html を参考に作った.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<title>タイマー</title>
</head>
<body>
<h1>タイマー</h1>
<p>カップラーメンの時間をはかったり,パスタの茹で時間をはかったりできる</p>
<div style="font-size:128px">
@myy
myy / Ripple.pde
Created November 29, 2012 01:38
マウスクリックまたはキータイプによる波紋のアニメーション.参考サイトは http://project-room.blog.ocn.ne.jp/blog/2009/05/processing_8774.html
float FRICTION = 0.985;
public class Ripple{
int x,y;
float dia;
float speed;
int colorH;
boolean flag;
Ripple() {
@myy
myy / cds2buzz.ino
Last active December 16, 2015 03:49
// cdsセルから読み取った値に応じて,ブザーの音程(発音)を制御するスケッチ
// ifで条件式を増やすことで,音程制御ができるようになる(はず)
// cdsセルから読み取った値が大きい→暗め
// cdsセルから読み取った値が小さい→明るめ
#include "pitches.h"
int val = 0; // アナログセンサから読み取った値用の変数
int inputPin = 0; // 入力センサのピン番号
@myy
myy / cds2led.ino
Last active December 16, 2015 03:49
// cdsセルから読み取った値に応じて,LEDのONとOFFを制御するスケッチ
int val = 0; // アナログセンサから読み取った値用の変数
int inputPin = 0; // 入力センサのピン番号
int outputPin = 13; // 出力センサのピン番号
void setup() {
Serial.begin(9600); // シリアルポートひらく
pinMode(outputPin, OUTPUT); // outputPinで設定したピン番号を出力モードにする
}
@myy
myy / rangeCheck.ino
Last active December 16, 2015 03:49
// 測距センサの値をシリアルモニタでチェックする
// 読み取ったセンサの値を視覚的にわかるようにシリアルモニタに表示する
// 対象との距離が近いほど数値が大きい.遠いほど数値が小さい.
void setup() {
Serial.begin(9600);
}
void loop() {
int val;
@myy
myy / range2buzz.ino
Last active December 16, 2015 03:49
// 測距センサで読み取った値を音に変換
// 8音(C4~C5)出せるようにする
#include "pitches.h"
int rangePin = 0;
int buzzPin = 13;
void setup() {
Serial.begin(9600);
// ボタンを押すと圧電ブザーが鳴るプログラム
// ドレミファソの5音が鳴る
// Bounceライブラリを使って,バウンシングに対応する
#include <Bounce.h>
#include "pitches.h"
int button1Pin = 10;
int button2Pin = 8;
int button3Pin = 6;