I’m prototyping a sound level meter for a physics experiment. I teach physics at a small college. I’m using the uLCD-32PTU-AR to display a meter to show max sound amplitude (using microphone breakout) and led digits to show ADC sample rate.
I am finding that if I use a Blackboard, the meter doesn’t work but the led digits do! When I use an Arduino Uno the display responds as expected.
Since the Blackboard is supposed to be compatible with the Uno, what could be going on?
I’ve attached a picture of my setup, my sketch, and the resource files for the display.
Do you have a link to that shield, LCD screen, and microphone(?) (I don’t think we carry some of those products)? Could the selectable I/O voltage be causing an issue?
When you say, “the meter doesn’t work but the led digits do,” are you referring to the green digits on the LCD screen?
Have you tried to debug the code to see if you are getting proper values for the meter? Try a simple Serial.print() function to output that value.
- Do the values look right?
- If there is no response, try to check your wiring to the analog pin.
- Try testing the analog pin with a simple analogread sketch and trimpot.
I bought all the parts from SparkFun - the 4d display shield for Arduino Uno (the red thing on top of my Arduino), the 4d display (the thing in foreground), the microphone breakout (the red thing in background on the breadboard).
If you look at my sketch, I have a “Serial.println(meterVal)” which I can compile back in by changing the “#if 0” to “#if 1”. The values on the serial monitor in this case are what I expect.
If I swap out the Arduino for the Blackboard (also from Sparkfun), the readings on the LED digits (on the LCD screen) are correct and update with each loop(). However, the meter on the display is stuck at 50 and does not respond, despite my whistling or clapping. Swap back in the Arduino and I’m back in business.
I’m not sure I fathom what you mean by “selectable I/O voltage” causing an issue. The Blackboard is unaltered as received from SparkFun.
I uploaded my sketch and the resource files to my original post. I was hoping someone at SparkFun could replicate the setup and confirm Blackboard doesn’t update the meter object for some reason. The components and part numbers are:
Microphone breakout INMP401 (ADMP401) part BOB-09868:
VCC → 3.3V,
GND → GND,
VOUT → A0
uLCD-32PTU-AR part LCD-11741 (comes with shield and cable), USB-to-Serial Bridge uUSB-PA5-II part DEV-15009 for programming display with 4D Workshop
An update … I set up a simple circuit with Blackboard and a potentiometer and wrote a small sketch to print out A0 every 0.5 seconds. Naturally, it works fine (see attached photo). The trace is serial plotter and me playing with potentiometer and A0 gives values from 0 to 1023.
I then put the 4D shield for Arduino (comes in the uLCD box along with the display and cable) and repeated the test with potentiometer. I got a similar plot with values ranging from 0 to 1023.
I believe this is pointing towards something in my sketch which gives different behavior depending on whether I’m putting the sketch on Ardunio Uno or Blackboard. So I will experiment with my sketch.
As a follow-up, I looked into what you found and it seems to be related to the CH340 Serial-to-USB converter used on the BlackBoard. It seems that the 16U2 used on the Arduino Uno emulates the functionality of a Serial-to-USB converter, but isn’t a true Serial-to-USB converter. Due to this, there are occasions where the Arduino Uno won’t run into bus contention issues that would normally happen on a true Serial-to-USB converter, like the CH340.
Your workaround of using SoftwareSerial using pins D2 and D3 is the actual fix for the bus contention issue.
*Glad you were able to work everything out. Sorry, it took me a while to dig into the exact problem.