MSGEQ7 chip to make graphic visualizer #484
Replies: 10 comments
-
Posted at 2014-05-11 by DrAzzy The arduino code has a delay between strobe and read. Your code does not. Could that be it? Maybe you want to "offset" your loop, so the delay between iterations falls the same place as the delay the arduino code. Though this is terrible practice on the espruino and contrary the event based philosophy... You can do this (i imagine this might be particularly useful for testing in particular so you can see if lack of delay some point is the problem - then if it is, you can go do it the right way):
Also, you know that analogRead on espruino returns a value between 0 and 1? I don't know if this is the same as the arduino |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-11 by Sacha AnalogRead on arduino returns a value between 0 and 1023. Sacha |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-12 by @gfwilliams I imagine @DrAzzy/@sacha are right here - analogRead on Espruino returns a value between 0 and 1. All you need to do to scale it up is to multiply it by 1024. The JS code looks good - the interpreter produces a little delay in the execution so the fact that you're not delaying after the strobe probably isn't a big deal. That doesn't explain the crash though. I'm trying it here and it's been fine for a few minutes so far... Are you using an up to date firmware? It could be there was a bug in an older version. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-12 by Owen I've fixed the crash, it was because I was re-declaring loop each time rather than once and then overriding it. I understand analogRead returns values between 0-1 but the values I get are so low I tihnk it's just background static. Changing the audio-in volume should change values at least. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-12 by @gfwilliams Ahh, great - did it come up with any kind of error, or did it just crash without warning? I just realised something - try replacing |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-12 by Owen No warning in the console or editor it just crashed after a few seconds. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-14 by @gfwilliams The static noise is a bit strange... Have you tried running it all from a battery in case it's some power supply issue? You could try adding a capacitor across the power lines on the breadboard? What size delay did you have to add? Personally, I'd try add code that's a bit more like:
Unlikely to solve the static, but it's better practice than adding a delay :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-19 by Owen Hi Gordon, Thanks everyone for you help, I've now got a kickass graphic visualizer. Here is a quick videos of it in action: http://youtu.be/oADZs-v-OUE (the code) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-20 by @gfwilliams That's great! I bet it's pretty brutal when you change the colour values from 0.05 to 1 :) It'd be great if you could write a tutorial for it! There's a bit on how to submit one here if it helps? http://www.espruino.com/Writing+Tutorials |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-05-11 by Owen
Hello,
I've bought a MSGEQ7 chip (https://www.sparkfun.com/datasheets/Components/General/MSGEQ7.pdf) and wired it up following this [http://nuewire.com/info-archive/msgeq7-by-j-skoba/](tutorial on nuewire.com)
See my wiring here: http://i.imgur.com/jUXKgNn.jpg?2
I ported the following code from the same tutorial:
The console.log() output looks like this: http://pastebin.com/DVMBQQ4Z
All of the numbers are very low and they don't seem to change when I in-decrease the volume or mute completely. After a few seconds it crashes but I think that's more to do with the console.log getting too big.
With the same wiring on Arduino and the code from the tutorial it seems work correctly, outputting higher/lower values depending on the music playing or not at all.
This makes me think it must be the JS code. Can you see any issues with it? I'm a little unsure about my use of the delayed loop to poll the chip but without a microdelay function I'm not sure how else to do it.
Any help you can offer would be great.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions