Эти красивым бесконечным зеркалом (Infinity Mirror), можно управлять с помощью своего телефона или планшета через Bluetooth. Кроме того, зеркало имеет встроенный микрофон, который позволяет ему реагировать на звук или музыку, создавая завораживающие световые стробы в ритме музыки.
Чтобы собрать такое зеркало, автору понадобились:
— контроллер Arduino Uno
— лента цифровых RGB-светодиодов WS2813
— Bluetooth-модуль HC-06
— модуль звукового сенсора
Схема подключения

Код для Arduino
#include <Adafruit_NeoPixel.h>
//Pins that are connected to the Arduino
const int PIN = 6; //The input pin of the LED strip
int NUMPIXELS = 144; //The number of pixels that will light up
const int SOUNDSENSOR = A0; //The input pin of the Sound Sensor
int ButtonState = 0; //State that is assigned to a button on the bluetooth app
int volume = 0; //State that checks if there is a signal in the microphone or not
//Color variables
boolean PrimBlue = false;
boolean PrimGreen = false;
boolean PrimRed = false;
boolean PrimWhite = false;
boolean PrimYellow = false;
boolean PrimOrange = false;
boolean PrimPink = false;
boolean PrimPurple = false;
//Light and sound variables
boolean SoundDetect = false;
boolean FullLight = false;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pinMode(SOUNDSENSOR, INPUT); //Input of the Sound Sensor
pinMode(PIN, OUTPUT); //Input of the LED strip
Serial.begin(9600);
strip.setPixelColor(0, 0, 0, 0);
strip.setBrightness(0);
strip.begin(); //This initializes the NeoPixel library
strip.show();
}
void loop() {
//Define the brightness amount according to the slider
byte brightness = analogRead(A0)/4;
Serial.println(brightness);
if (Serial.available() > 0) {
ButtonState = Serial.read();
}
//Enable or disable LED and Sound Detection
if (FullLight == 1 && SoundDetect == 0) {
strip.setBrightness(ButtonState);
strip.show();
}
else if (FullLight == 0 && SoundDetect == 0) {
strip.setBrightness(0);
strip.show();
}
else if (FullLight == 0 && SoundDetect == 1) {
strip.setBrightness(brightness);
strip.show();
}
else if (FullLight == 1 && SoundDetect == 1) {
strip.setBrightness(0);
strip.show();
}
//////////////////////////LED switch//////////////////////////
if (ButtonState == 'a') {
primaryColors();
FullLight = 1;
SoundDetect = 0;
}
if (ButtonState == 'b') {
FullLight = 0;
SoundDetect = 0;
}
//////////////////////////Sound detection switch//////////////////////////
if (ButtonState == 'c') {
primaryColors();
SoundDetect = 1;
FullLight = 0;
}
if (ButtonState == 'd') {
SoundDetect = 0;
FullLight = 0;
}
//////////////////////////Primary Colors//////////////////////////
if (ButtonState == '1') {
primaryColors();
PrimBlue = 0;
PrimGreen = 0;
PrimRed = 1;
PrimWhite = 0;
PrimYellow = 0;
PrimOrange = 0;
PrimPink = 0;
PrimPurple = 0;
}
if (ButtonState == '2') {
primaryColors();
PrimGreen = 1;
PrimBlue = 0;
PrimRed = 0;
PrimWhite = 0;
PrimYellow = 0;
PrimOrange = 0;
PrimPink = 0;
PrimPurple = 0;
}
if (ButtonState == '3') {
primaryColors();
PrimRed = 0;
PrimBlue = 1;
PrimGreen = 0;
PrimWhite = 0;
PrimYellow = 0;
PrimOrange = 0;
PrimPink = 0;
PrimPurple = 0;
}
if (ButtonState == '4') {
primaryColors();
PrimRed = 0;
PrimBlue = 0;
PrimGreen = 0;
PrimWhite = 1;
PrimYellow = 0;
PrimOrange = 0;
PrimPink = 0;
PrimPurple = 0;
}
if (ButtonState == '5') {
primaryColors();
PrimRed = 0;
PrimBlue = 0;
PrimGreen = 0;
PrimWhite = 0;
PrimYellow = 1;
PrimOrange = 0;
PrimPink = 0;
PrimPurple = 0;
}
if (ButtonState == '6') {
primaryColors();
PrimRed = 0;
PrimBlue = 0;
PrimGreen = 0;
PrimWhite = 0;
PrimYellow = 0;
PrimOrange = 1;
PrimPink = 0;
PrimPurple = 0;
}
if (ButtonState == '7') {
primaryColors();
PrimRed = 0;
PrimBlue = 0;
PrimGreen = 0;
PrimWhite = 0;
PrimYellow = 0;
PrimOrange = 0;
PrimPink = 1;
PrimPurple = 0;
}
if (ButtonState == '8') {
primaryColors();
PrimRed = 0;
PrimBlue = 0;
PrimGreen = 0;
PrimWhite = 0;
PrimYellow = 0;
PrimOrange = 0;
PrimPink = 0;
PrimPurple = 1;
}
}
void primaryColors() {
for (int i = 0; i < NUMPIXELS; i++) {
if (PrimBlue == 1) {
strip.setPixelColor(i, 0, 0, 255);
}
else if (PrimGreen == 1) {
strip.setPixelColor(i, 0, 255, 0);
}
else if (PrimRed == 1) {
strip.setPixelColor(i, 255, 0, 0);
}
else if (PrimWhite == 1) {
strip.setPixelColor(i, 255, 255, 255);
}
else if (PrimYellow == 1) {
strip.setPixelColor(i, 255, 255, 0);
}
else if (PrimOrange == 1) {
strip.setPixelColor(i, 255, 102, 0);
}
else if (PrimPink == 1) {
strip.setPixelColor(i, 255, 0, 255);
}
else if (PrimPurple == 1) {
strip.setPixelColor(i, 102, 0, 204);
}
else {
strip.setPixelColor(i, 255, 255, 255);
}
}
strip.show();
}
Ссылки
Arduino Infinity Mirror (Bluetooth & Sound Reactive)
По теме
RGB-светодиод
Лампа настроения из Arduino
Самодельный интерактивный кофейный столик
Разноцветное облако при помощи Arduino
Cryoscope - куб чтобы потрогать погоду
Музыка ветра от Winduino
Робот Qbo и зеркало
Arduino
Ардуино что это и зачем?
Arduino, термины, начало работы
КМБ для начинающих ардуинщиков
Состав стартера (точка входа для начинающих ардуинщиков)
