Need help to realize loudness indicator


#1

Hi

I am trying to design some code with mBlock. That case is like a loudness indicator which show the accumulated LED number by the sound loudness in real time. Of course it require the sound sensor and LED RGB strip. Anyone else who has made this case, and can share with me?

Thanks!


#2

here is a tiny little program that moves the panda up and down depending on how loud the PC mic detects sound

The main issue I need to point out is that the microphone is on the PC and not the robot which means you can’t download this program to the robot. The other is obviously that the movement of the panda (sprite) isn’t something the robot is going to do either.
You could try to change the brightness of the onboard LED based on the reading from the microphone. All of this really requires you to adjust the raw output to match the levels you need depending on your output device.
I usually prototype it with some variable that I watch on mBlock to get a feel for the range of values.


#3

ok, because I thought it would be cool, I decided to make a simple volume tracing program.


which makes the panda slide across row by row with different colors showing a VU meter trace.


#4

Thanks Danjger!

It is impressive to see your comments. It is true to help me out to understand more about this mission. However I want to find more decisive clue by discussing on the Scratch code. Here I would show you what I am exactly struggling with. It has been reverse engineered into Scratch with what Trapasis has provided. But it did not work and halted. Please check this and share your thinking.


Thanks in advance!


#6

@indream Ander, please share more information about how to make rbg stripe work with sound sensor. Thanks!


#7

As I checked with Makeblock team and simulated with my Makeblock LED RGB Strip, this block can translate all numbers into each LEDs. Also Makeblock team said this block is kinds of workaround for LED strip.
However, I think I have mistake on my coding scheme which is related the variables lastNum, x and getSound. These variables should be co-worked by circulating each state. It is easy in C code, but I cannot find that way in the scratch. Maybe it caused from my lack of background for Scratch coding.


#8

If you don’t mind, can you share your code here and i would ask for our engineer to check for you.
Thanks


#9

Please refer this code. Thanks!

loudness_Idicator.zip (38.7 KB)


#10

I’m ordering some rgb strips to see how this all works. If the strips LEDs are addressable loads of cool things can be done.


#11

Got it, will transfer to our engineer and reply it later. Thanks


#12

Thanks, Una!

I would be appreciated if I can also share the explanation on what I`ve missed during the this code making.


#13

@notego , I use the mBlock to control led strip by sound sensor, and there is a video that the project shows.


project.sb2 (74.6 KB)

wiring


#14

Awesome! We need more of these.


#15

It`s impressive. However, could you kindly explain me why you have to make in this way? Is there any reason from the feature of Scratch programming compared with C code? I am specially curious about the variable “ledCurrent” for what purpose and How it has been designed. Thanks!


#16

@notego Click “Makeblock Program” hat, and mBlock will switch to the arduino mode. We can compile and upload the program to arduino board.
ledCurrent is a variable for led step-by-step changed.

ledCurrent -= (ledCurrent - ledMax)*0.1;
ledMax is target value decided by the loudness.


#17

LED Color Loop Project for mBlock: colorloop.sb2 (74.7 KB)
Video:


#18

Thanks, it was very helpful!
A question. Why did you intend to have 32 time- loop at every round? According to this scheme, It seems to cause late activation of LEDs in case loudness is increased at the initial time.


#19

The count of leds on my led strip is 32. You can change the count according to your led strip.


#20

I mean there will be new way to avoid all 32 LEDs checking at every round and make faster.

Let me share also one more thought and request.
I think “make a block” of Scratch does not allow global variable or there seems to be no such concept. My trial in scratch code above has made assuming variable “lastNum” as global variable in make-a-block “Indicators”. Can you help me to find any white paper or tutorial for Scratch coding rule (syntax and grammar)? I cannot even find it in Scratch WiKi.


#21

scratch official wiki: http://wiki.scratch.mit.edu/wiki/Scratch_Wiki_Home
http://wiki.scratch.mit.edu/wiki/Remote_Sensors_Protocol
extension protocol: http://wiki.scratch.mit.edu/wiki/Scratch_Extension_Protocol_(2.0)
block: http://wiki.scratch.mit.edu/wiki/Code