見出し画像

Lチカで作る「流れ星プラネタリウム」 =最も簡単な装備で壮大な感動を作る練習。

Lチカとは「LEDをチカチカさせる」という言葉の略称。マイコンを使ってLEDを点滅させることだというのを初めて知った。プログラミングの世界でいう第一歩、「Hello World」と同義語なのだそう。その理解がちょっと面白いな、と思った。

2023年夏の制作物:

この夏、デジタルハリウッド大学大学院で「プロダクトプロトタイピング」を学んだのだが、初めてプログラミングした「Lチカ」は、そのプログラミング工作の楽しさとともに言葉の意味にも惹かれていた。

アイデアスケッチ

プログラミング工作の基本中の基本を使って、夏らしいメディアアートは作れないものか。そんなことを考えていたのだが「流れ星プラネタリウム」を作ってみるのはどうか、と思いついた。現在、私自身のアート制作のテーマが「儚さ」や「有るか無いかの間」ということもあり、メディアアート制作のMVPとして、2023年の夏らしい企画になるなと思った。

canvaってほんと便利。サクッとまとめられる。

基本的装備:

Obniz 1台
LED (白色灯のような白)
圧電スピーカー 1機
コンテクター付きケーブル20センチ

秋月電子にお世話になった。中身を見ないと袋はパン屋さんのよう。
LEDは3Wの極小にしたが、これでも明るすぎたので、
半分以上を「MUSO BLACK」で塗り込んだ

「Lチカ」と共に圧電スピーカーで音を出すことを考えた。星にちなみ「きらきら星」。スピーカーが鳴らす音の高さをヘルツ数で選んで、曲にする。少しずつ音を上げていき、最終的にはE♭ majorになった。

作業記録:ヘルツ数で音を指定。

思ったようにならない。。。

ブレッドボードにLEDを刺し、ブレッドボードの重みで揺らそうと考えていたがLEDに照らされたボードがバレバレで、星どころか四角いプラスチックがゆらゆらするだけだということに気づいた。(だけどさあ、なんで最初に気づかないんだ、わたし苦笑!)

あれ?裏方装備がバレバレ。

ブレッドボードをやめて、コネクトケーブルに直接LEDを指すことにしたのはいいが、今度は軽すぎて、虫が飛んでいるかのように。。。😭


なんとかなってきた!!

練り消しゴムを魚釣りのおもりのようにつけることにした。振り回すと綺麗な弧を描いた!

練り消しゴムは簡単に重量調整できるし、形も整えやすくて良かった。

できたのはこちら!


最後の演出:

パフォーマンスの最後は、圧電スピーカーで「星に願いを」を奏で、最後にLEDが消えると、体験者のケータイにLINEBotから「おやすみなさい。良い夢を」のメッセージが送れられるようにした。
ちょっと可愛い体験になったと思う。

コードはこちら

'use strict';

const Obniz = require('obniz');
const obniz = new Obniz("6788-____");
const express = require('express');
const line = require('@line/bot-sdk');

const PORT = process.env.PORT || 3000;

const config = {
    channelSecret: 'yours',
    channelAccessToken: 'yourToken'
};

const client = new line.Client(config);

obniz.onconnect = async function () {
        // スピーカーを呼び出す
        const speaker = obniz.wired('Speaker', {signal:0, gnd:1});
        
        // ピンのオブジェクトを先に取得
        const ledPlus = obniz.io10;
        const ledMinus = obniz.io11;
        
        // ピンを出力モードに設定し、LEDを初期状態にする
        ledPlus.output(false);
        ledMinus.output(false);
        
          async function playAndIlluminate(freq, duration, pause) {
              ledPlus.output(true);  // LEDをONにする
              speaker.play(freq); // 音を鳴らす
              await obniz.wait(duration); // 待つ
              speaker.stop(); // 音を止める
              ledPlus.output(false); // LEDをOFFにする
              await obniz.wait(pause); // pauseミリ秒待つ
          }
        
          await playAndIlluminate(1244.508, 400, 600); 
          await playAndIlluminate(1244.508, 400, 600);
          await playAndIlluminate(1864.655, 400, 600);
          await playAndIlluminate(1864.655, 400, 600);
          await playAndIlluminate(2093.005, 400, 600);
          await playAndIlluminate(2093.005, 400, 600);
          await playAndIlluminate(1864.655, 1000, 1000);
          await playAndIlluminate(1661.219, 400, 600);
          await playAndIlluminate(1661.219, 400, 600);
          await playAndIlluminate(1567.982, 400, 600);
          await playAndIlluminate(1567.982, 400, 600);
          await playAndIlluminate(1396.913, 400, 600);
          await playAndIlluminate(1396.913, 400, 600);
          await playAndIlluminate(1244.508, 1000, 1000);
        
          await playAndIlluminate(1864.655, 400, 600);
          await playAndIlluminate(1864.655, 400, 600);
          await playAndIlluminate(1661.219, 400, 600);
          await playAndIlluminate(1661.219, 400, 600);
          await playAndIlluminate(1567.982, 400, 600);
          await playAndIlluminate(1567.982, 400, 600);
          await playAndIlluminate(1396.913, 1000, 1000);
          await playAndIlluminate(1864.655, 400, 600);
          await playAndIlluminate(1864.655, 400, 600);
          await playAndIlluminate(1661.219, 400, 600);
          await playAndIlluminate(1661.219, 400, 600);
          await playAndIlluminate(1567.982, 400, 600);
          await playAndIlluminate(1567.982, 400, 600);
          await playAndIlluminate(1396.913, 1000, 1000);
        
          await playAndIlluminate(1244.508, 400, 600); 
          await playAndIlluminate(1244.508, 400, 600);
          await playAndIlluminate(1864.655, 400, 600);
          await playAndIlluminate(1864.655, 400, 600);
          await playAndIlluminate(2093.005, 400, 800);
          await playAndIlluminate(2093.005, 400, 850);
          await playAndIlluminate(1864.655, 1000, 1100);
          await playAndIlluminate(1661.219, 400, 700);
          await playAndIlluminate(1661.219, 400, 750);
          await playAndIlluminate(1567.982, 400, 700);
          await playAndIlluminate(1567.982, 400, 900);
          await playAndIlluminate(1396.913, 400, 1100);
          await playAndIlluminate(1396.913, 400, 1100);
          await playAndIlluminate(1244.508, 1300, 2000);
        
          await playAndIlluminate(1318.510, 100, 5);
          await playAndIlluminate(1396.913, 100, 5);
          await playAndIlluminate(1479.978, 100, 5);
          await playAndIlluminate(1567.982, 100, 5);
          await playAndIlluminate(1661.219, 105, 5);
          await playAndIlluminate(1760.000, 110, 10);
          await playAndIlluminate(11864.655, 200, 100);
          // await playAndIlluminate(11975.533, 200, 80);
        
          await playAndIlluminate(1046.502, 900, 100); 
          await playAndIlluminate(2093.005, 900, 100);
          await playAndIlluminate(1864.655, 900, 100);
          await playAndIlluminate(1760.000, 900, 100);
          await playAndIlluminate(1479.978, 900, 100);
          await playAndIlluminate(1567.982, 900, 100);
          await playAndIlluminate(2349.318, 1950, 50);
          await playAndIlluminate(1318.510, 900, 100);
          await playAndIlluminate(2637.020, 900, 100);
          await playAndIlluminate(2349.318, 900, 100);
          await playAndIlluminate(2093.005, 900, 100);
          await playAndIlluminate(1975.533, 900, 100);
          await playAndIlluminate(2093.005, 900, 100);
          await playAndIlluminate(2793.826, 2000, 10);
        
          await playAndIlluminate(3135.963, 900, 100); 
          await playAndIlluminate(2793.826, 900, 100);
          await playAndIlluminate(2637.020, 900, 100);
          await playAndIlluminate(2349.318, 900, 100);
          await playAndIlluminate(2093.005, 900, 100);
          await playAndIlluminate(1864.655, 900, 100);
          await playAndIlluminate(1760.000, 900, 100);
          await playAndIlluminate(1567.982, 900, 100);
          await playAndIlluminate(2349.318, 1950, 50);
          await playAndIlluminate(2637.020, 1950, 50);
          await playAndIlluminate(2793.826, 3500,1000);
        
        
          // ディスプレイ処理
          obniz.display.clear();  // 一旦クリアする
          obniz.display.print('Twinkle Twinkle Little Star');  // 文字を出す

          await sendLineMessage();
        }

    // LINEにメッセージを送信する関数
    async function sendLineMessage() {
        try {
            await client.pushMessage('YourId', {
                type: 'text',
                text: 'おやすみなさい。よい夢を',
            });
            console.log('Message sent!');
        } catch (error) {
            console.error('Error sending message:', error);
        }
    }
const app = express();

app.listen(PORT, () => {
    console.log(`Server running on port ${PORT}`);
});

最後に

授業のプレゼンテーションではクラスメイトに床に寝転んでもらい、頭上で「Lチカ」をさせたのですが
教室は暗くならないし、暗幕も張れないので「流れ星」を感じるには程遠かったかもしれない。としても、大の大人が地べたに寝転んで、光の軌跡を眺める時間を作れただけでも、ある意味、成功だったと思う。


この記事が気に入ったらサポートをしてみませんか?