Arduino CV to midi CC

Analog Input

Analog Input pins are used to measure a voltage. Sometimes I see people use Arduino’s pinMode() to configure it as an INPUT. However, this is not necessary, for two reasons.

  1. pinMode() sets up a pin for use as a digital input, not analog input.
  2. When calling analogRead (), it reconfigures the Analog Pin for “input.”
3 Likes

If there’s nothing connected to the pin, no pullup/pulldown, you’ll get random values — it’s floating, no well defined voltage.

4 Likes

So the pinmode statements are setting them as digital ON/OFF pins, which concurs with your findings.

1 Like

Or is your abbreviated code only what’s there, but i can’t see “analogpin” defined?

That’s weird. I swear I copied it… Well it’s in the code. I just apparantly didn’t copy it over. That’s the only line missing from the code though.

Oh my… I told myself I wouldn’t get into arduino, that would take the diy synth stuff too far. Well. Here we go! Now I need this module… So I better start reading up!

Edit: Editing this post so I won’t spam everything… Uno seems to be working great! I’ll try and troubleshoot the nano next week.

3 Likes

Another subtlety at least on the Nano, Analog inputs A0-A5 can be used as INPUT_PULLUP (for digital inputs), but not A6 and A7. Those ones are just for analog in. Learned that the hard way. The pinmode function has no impact on those two pins.

3 Likes

Yeah, the Arduino folks are perhaps a bit too good at hiding the underlying mechanisms; for Arduino’s with 32-pin 328Ps, A0-A5 share the pins with GPIO port C which gives you the full GPIO machinery, while A6 and A7 go directly to the ADC’s mux.

4 Likes

UniConverter_20200605010735

A gif of the code in action! Hooray!

6 Likes

Shhhh! They’ll all want one!

1 Like

Yeah, it’s prety darn cool when you interface from hardware to software yourself.

Good work :wink:

3 Likes