
Lab:Let’s LEDS singing
This experiment, I want to let the Led lights sing by themselves.
I used the random() function to make the six LEDs randomly lit, and set a calculation parameter m. At the same time, with the buzzer, when the total number of flashing lights of the bulb is 1, the ‘dao’ pronunciation is issued, When m is 2, the sound of ‘rai’ is emitted. When the total number of flashing lights of the bulb m is 3, the sound of ‘mi’ is emitted, and so on.
Tool:
6 LEDS, Buzzer, use cable, Arduino NANO 33 IOT…
code:
int ports[6]={5,6,9,10,11,12};
int value;
void setup() {
Serial.begin(9600);
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
// put your setup code here, to run once:
}
void loop() {
int m=0;
for(int i=0;i<6;i++)
{
if (random(0,10)>5){value=0;}else{value=1;}
digitalWrite(ports[i], value);
if(digitalRead(ports[i])==1)
{ ++m%=7;
}
}
Serial.println(m);
delay(100);
switch(m){
case 1:{
analogWrite(3,200);
tone(3,2093,100);
delay(100);
}
case 2:{
analogWrite(3,200);
tone(3,2349,100);
delay(100);
}
case 3:{
analogWrite(3,200);
tone(3,2637,100);
delay(100);
}
case 4:{
analogWrite(3,200);
tone(3,2794,100);
delay(100);
}
case 5:{
analogWrite(3,200);
tone(3,3136,100);
delay(100);
}
case 6:{
analogWrite(3,200);
tone(3,3520,100);
delay(100);
}
}
}
Breadboard diagram

Observation
For this observation, I chose an interactive installation on the fourth floor of The RUBIN Museum.The interaction with the audience is a circular gauze. When people touch the gauze, there will be sounds and graphics, and as the person moves, the image changes. At the same time, the part touched by the finger is the darkest.With depth sensor, when the distance of the object(visitors)reaches a certain range, The sensor senses the change and delivers images and sounds.
