Please click “WEEK 6” to go to the page.
Please click “WEEK 5” to go to the page.
Last week, I planned to make a music band like speaker Acapella. But I got into troubles that the two speaker cannot sing at the same time and the effect was not what I want as the speaker voice was quite noisy and not beautiful enough if I controlled badly. The thing was that I tried to make two speakers singing at the same time. One speaker was controlled by potentiometer and another one is by force sensor. I booked an office hour with resident for this problem but after her research, it seemed two speaker cannot make sound at the same time using the tone(); (I spent 6 hours on am impossible thing).I struggled with questions for long then decided to change my project plan.
Here is some reference of tone() that Yeseul and Nun sent me:
For now, I use LDR to control the buzzer output. I put them in an umbrella. Once the value of LDR is greater than 50, the buzzer starts to sing “Mia and Sebastian’s Theme” (Lala Land) and it stops singing when I fold it as well as getting darker. I think it might be quite romantic in rainy day. The problem in the first coding I wrote was that I put too many delay(); there. Instead, I should use millis(); Another thing is that it cannot stop immediately when I put it in dark while buzzer is singing. It means that sensor stops sense the value once if() statement starts and it starts to sense again when all the tone() and delay() in this loop are finished. So I asked a resident YG, he told me that I should add if() statement before each tone() so it can sense for whole time. Another second year student told me millis() is able to solve it. But I am still confused about how to use millis() after watching tutorials on Youtube.
At the first step, I wrote down the numbered musical notations of this song “Mia and Sebastian’s Theme” and then tested tone frequency, finding the right pitch. Then test duration for right rhythm. I was aware of that I should strongly pay attention to using the right resistor in the process. And Serial.println() is a good way to debug. I fixed board to umbrella with tape and connected board with 5v power bank.
I enhanced the circuit, adding LEDs which triggered by the value of photoresistor (LDR). When value of LDR is in different range (0-15, 15-30, >30), different LEDs will be lightened. The problem mentioned above is solved.
Thanks: Yeseul, Nun, YG
1. I solved the NANO board problem with resident’s help. Check all of tools bar to choose the right board.
2. Try another board if there is an error.
3. tone(pin, frequency, duration); delay(); I feel like I could make a band by control the frequency, duration and delay of the speaker. tone(pin, frequency, duration).
4. Serial.println(); is a good way to debug.
I tried control the speaker by force sensor and potentiometer.
Server Motor control
1. I spent much time on distinguishing INPUT and OUTPUT. What situation the pin will be INPUT or OUTPUT. For example, in Lab 1 circuit, I found that the pin connecting with LED is OUTPUT, because current flows from pin to the LED and the to the ground. Pin here outputs the electricity. As for pin connecting with switch(button), voltage comes from breadboard, flowing to pin and ground. Pin here inputs the electricity and then receive signal for HIGH or LOW.(I am not sure if I explain right???)
LAB1: Control the LEDs by pushing a button.
Red and yellow LED are lighted when pushing the button.
LAB 2: Use a potentiometer
I failed making it in NANO board. I am trying to figure out what is the problem.
I tried the same circuit using UNO and NANO. It works on UNO but fails on NANO. Uploading on NANO is very slow and not working.(?)
Measure a force sensor.