![]() |
![]() | ![]() |
この回路を作る | 上部右側ピンがGND(-) 上部左側ピンが3.3V(+) |
寸法 |
![]() |
![]() |
![]() |
ブレッドボード 赤、青は電源用の部分で直線が繋がっています。 黄色の5つはそれぞれ繋がっています。 この性質を利用して回路を作ります。 | マイクをこの方向に差し込みます | このように接続し、動作チェックします。 隣の素子(抵抗、コンデンサ)と接触しない ように注意します。 |
![]() |
![]() |
|
抵抗とコンデンサの足を7mmぐらいで ニッパーを用いて切断し、差し込むと隣と接触 することはなくなります。 緑の線が出力でE1に接続。青の線がGNDでE8に接続。 |
部品の部分だけ真上から見る 13のラインがGND、16のラインが出力 |
びっくり猫 | |
---|---|
public partial class Program { // x y static BrainPad.Display.Image cat1 = new BrainPad.Display.Image(32, 37); static BrainPad.Display.Image cat2 = new BrainPad.Display.Image(32, 37); static ADcon mic; private void main() { BrainPad.Display.Clear(); BrainPad.LightBulb.SetColor(BrainPad.Color.Black); // Resourceを追加するとBinaryResourcesが追加される getResourceBmp(cat1, Resources.BinaryResources.cat1_a); getResourceBmp(cat2, Resources.BinaryResources.cat1_b); mic = new ADcon(CPU.E1); while (true) { BrainPad.Display.DrawImage(64, 80, cat1); checkMic(500); BrainPad.Display.DrawImage(64, 80, cat2); checkMic(500); } } static void jump() { BrainPad.Display.DrawFilledRectangle(64, 80, 32, 37, BrainPad.Color.Black); BrainPad.Display.DrawImage(64, 20, cat1); Thread.Sleep(1000); BrainPad.Display.DrawFilledRectangle(64, 20, 32, 37, BrainPad.Color.Black); } static void checkMic(int n) { for (int i = 0; i < n; i++) { if (mic.Read() > 0.505) { jump(); return; } Thread.Sleep(1); } } static void getResourceBmp(BrainPad.Display.Image image, Resources.BinaryResources id) { byte[] z = (byte[]) ResourceUtility.GetObject(Resources.ResourceManager, id); //32*37=2368 BrainPad.Color color = new BrainPad.Color(); int dt = 0x42; // BMPのデータ開始アドレス for (int Y = image.Height - 1; Y >= 0; Y--) { for (int X = 0; X < image.Width; X++) { // ピクセルデータの取得 byte d = z[dt++]; byte e = z[dt++]; color.B = (byte)(d & 0x1f); color.G = (byte)(((d & 0xe0) >> 5) + ((e & 0x07) << 3)); color.R = (byte)((e & 0xf8) >> 3); image.SetPixel(X, Y, color); } } } } |
1 2 3 4 5 6 マイクの音をアナログ入力する 7 音がしたかのチェック 8 9 10 11 12 13 14 マイク入力ははE1に接続する 15 16 17 大きい音がしたらジャンプする 18 19 20 21 22 23 24 猫をジャンプさせる 25 26 27 28 29 30 31 32 33 1ms毎にマイクのチェック 34 35 大きい音の検出。0.5が無音 36 37 38 39 40 41 42 43 説明は前項にしている 44 ので上記を参照してください 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |