danct12, to Arduino
@danct12@fosstodon.org avatar
ottaross, to Arduino
@ottaross@mastodon.social avatar

I picked up a few of these nameless -ish boards from . They have the ATMega4808 on them, similar to an Arduino "Every" which has the '4809.

At $4.50 ea it's a good deal.

Programming is a bit different with the library involved, and wiring up a Nano as a programmer.

Will tack on some threaded cmts about how it goes. A bit cryptic so far, but thankfully not much cash nor time invested yet.

ottaross,
@ottaross@mastodon.social avatar

I've had some luck with that board as far as getting an wired up as programmer and using the code to push a 4808-friendly bootloader onto the device.

A problem though has brought me back into the nuances of the serial chip world, which I had hoped I was done with yrs ago.

Seems maybe older MacOS versions have probs with CH340K vs G vs other variants.

I'm still on BigSur though, so perhaps this is reason to increment up to Ventura.

itnewsbot, to Arduino
@itnewsbot@schleuss.online avatar

Robot Pianist Runs on Arduino Nano - The piano has been around for a long time now. Not long after its invention, human... - https://hackaday.com/2023/12/01/robot-pianist-runs-on-arduino-nano/

diyelectromusic.wordpress.com, to random

This is a bit of an odd one, but I was asked to put something musically related together as a game to get in the spirit of the season, so I thought something along the lines of an Arduino adjustable tone generator with the aim being the player has to tune it by ear to as close to concert A – 440Hz – as possible.

This shows how I used my Nano Audio Experimenter Sheild PCB to do it. Note, as with most of my builds, this isn’t particularly mechanically satisfying, but it did the job 🙂

Warning! I strongly recommend using old or second hand equipment for your experiments. I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

  • Nano Audio Experimenter Sheild PCB.
  • Arduino Nano.
  • SSD1306 OLED display.
  • 1x temporary make, toggle switch.
  • Amplification and audio connections.
  • Power – either (micro) USB or a 7-9V barrel jack.

The Circuit

This uses the Nano Audio Experimenter Sheild PCB with the following configuration:

  • No DAC fitted.
  • Audio tone output via D3 through the audio output stage.
  • Audio GND jumpered across to digital GND via DAC header (see later).
  • SSD1306 OLED display fitted.
  • Switch connected to a free IO pin (recommend D4-D6).
  • No MIDI circuitry required.
  • Powered either by 7-12V barrel jack or 5V USB direct to the Nano.

https://diyelectromusic.files.wordpress.com/2023/12/arduino-frequency-game-1.png?w=1024The photo shows the key configuration options. To get an audio output whilst using PWM, the analog GND portion of the board needs connecting to the main GND. This can be done by adding a link between the two holes highlighted below:

https://diyelectromusic.files.wordpress.com/2023/12/nanoaudioexperimentershield-pcb-gnd-link.png?w=669In my case, as I’m using a pre-build PCB I’ve added a separate single-pin header socket which then can be used to jumper across these two connectors without removing the future ability to use a DAC again.

The frequency is set using all three pots. This gives a lot more variability as a game than using a single pot. The OLED display is used to show the frequency once it has been chosen. This happens while the switch is pushed.

The Arduino tone function will be used, which provides a 0-5V DC biased square wave output. Sending this through the audio filter and output stage means that the voltage is reduced (via the resistor potential divider) and the DC bias is removed (via the coupling capacitor) so it can be used as a more typical audio line output and connected to an old amp or similar.

There are a number of options where a GPIO pin is available via a header which can then be used to connect to a simple push switch:

  • Top: D9 is exposed in the PWM output jumper (which is set to select D3).
  • Far Right: D4-6 are exposed for use with an analog multiplexer.
  • Right: D7 is also exposed both in the jumper that can be used to set the behaviour of S4 and (assuming the jumper is actually set to make the link) D7 becomes exposed on the far right header too.
  • Far Right: A3 is also exposed on the far right header and so could also be used if required.

The downside of all of these is that my ready-made board requires header pin sockets which isn’t particularly robust for a game.

Advanced Option

But then I realised there is one additional pin exposed in a way that could still be used as an input but with a far more robust connector. D1 (TX) is linked to the MIDI OUT 5-pin DIN socket too, albeit via a 220Ω resistor. This means that I also have the option of connecting a switch across a 5-pin DIN Socket’s pins 2 (GND) and 5 (TX) and using that instead. The 5 pin DIN socket makes a much stronger and robust connection to the board, even if it is a little unconventional.

WARNING: The switch must NOT be connected between pins 4 and 5, which are the normal MIDI connections or from pin 4 to GND. Depending on the configuration used, there is a risk of connecting 5V to GND in the Arduino Nano and shorting something out. You might get away with it, depending on which resistors you end up having in the circuit (5V / 220Ω is just under 30mA), but it is really important to double checking the wiring before use!

Here is a “from the front/plug side” and “from the back/wiring side” view of a 5-pin DIN plug showing which pins are 5 and 2.

https://diyelectromusic.files.wordpress.com/2023/12/arduino-frequency-game-2.png?w=451Using D1 this way means that the serial port cannot be used (even though this project isn’t using MIDI) as TX is now being reconfigured as an INPUT.

RX isn’t an option as a populated MIDI circuit has an optoisolator between the external DIN socket and the GPIO pin.

Of course if a new PCB is being used, the MIDI section can be left unpopulated and it would then be possible to directly connect one of the MIDI sockets to either RX or TX. But for this project I’m just planning on reusing my generic, fully populated board, hence RX is not an option.

The Code

The basic tone generation is simply the Arduino tone function (more here). The frequency is a simple sum of the three potentiometers giving a range from 0 up to 3069. In musical terms this spans the range of notes from A0 (and lower) almost up to G7 (just over 3kHz).

Once the choice of frequency has been made, by ear alone, the button can be pressed and the display used to show both the frequency chosen and the numerical difference from 440Hz. The winner is the person closest to 440Hz.

To add an additional feeling of skill, but in reality to add a dose of luck, I’ve added two decimal points in the display which are actually randomly chosen each time the button is pressed. The idea being that if two players both get a pretty close 440Hz then the winner is essentially selected by random!

In order to avoid having to do decimal arithmetic in the code however, when calculating the difference I’m multiplying the frequency by 100, adding in the (random) decimal as if it was just a number between 0 and 99 and then comparing the result to 44000.

D3 is selected as the audio output and D4 is selected as the trigger button for the display using the following two lines:

int SPEAKER = 3;<br></br>int TRIGGER = 4;

Additional notes from the code:

  • I’ve implemented a software smoothing algorithm for the reading of the potentiometers in an attempt to remove some jitter. Although again a small amount of jitter brings another element of luck into the game.
  • When printing out, I have to take care of blank spaces in the frequency to keep the decimal point aligned for anything from 1 to 4 digits; but also have to allow for an extra leading zero in the case of randomly selecting a decimal in the range 0.01 to 0.09.
  • I’m using the Adafruit GFX and SSD1306 libraries for the Arduino.
  • When the button is pressed, the display changes to show the frequency. When it is released the frequency is hidden again.

https://diyelectromusic.files.wordpress.com/2023/12/img_7478.jpg?w=1024https://diyelectromusic.files.wordpress.com/2023/12/img_7479.jpg?w=1024Find it on GitHub here.

Closing Thoughts

This was a bit of a diversion and I could have easily knocked something up from solderless breadboard or stripboard with some pots and a display. But being able to just grab the PCB and experiment with the code made putting it together pretty easy.

Kevin

https://diyelectromusic.wordpress.com/2023/12/01/arduino-guess-the-frequency-game/

image/png
image/png

itnewsbot, to Arduino
@itnewsbot@schleuss.online avatar

Arduino Sticker Dispenser Saves Time - What’s the worst part about packaging up a whole lot of the same basic thing? It m... - https://hackaday.com/2023/11/12/arduino-sticker-dispenser-saves-time/ -17

itnewsbot, to Arduino
@itnewsbot@schleuss.online avatar

2023 Halloween Hackfest: Converted Proton Pack Lights Up the Night - It’s really quite unfortunate that Hackaday/Supplyframe employees and their famili... - https://hackaday.com/2023/10/31/2023-halloween-hackfest-converted-proton-pack-lights-up-the-night/

itnewsbot, to random
@itnewsbot@schleuss.online avatar

2023 Halloween Hackfest: Quoth the Raven, “Caww!” - Sometimes, projects start in somewhat unlikely places. This one began when Istvan... - https://hackaday.com/2023/10/31/2023-halloween-hackfest-quoth-the-raven-caww/ [

itnewsbot, to Arduino
@itnewsbot@schleuss.online avatar

2023 Halloween Hackfest: Treat Trough of Terror Is Actually Pretty Cute - Even though it seems the worst of COVID has passed, October generally kicks off co... - https://hackaday.com/2023/10/03/2023-halloween-hackfest-treat-trough-of-terror-is-actually-pretty-cute/ -to

itnewsbot, to random
@itnewsbot@schleuss.online avatar

Musical Robot Lets You Play the Recorder Hands-Free - Although many people might remember the recorder as just a simple instrument from ... - https://hackaday.com/2023/05/29/musical-robot-lets-you-play-the-recorder-hands-free/

itnewsbot, to random
@itnewsbot@schleuss.online avatar

Converting A B&W Exposer Head For Colour Analog Photo Printing - [Koraks tinkers] was gifted a gargantuan photographic enlarger, a Durst Laborator ... - https://hackaday.com/2023/05/08/converting-a-bw-exposer-head-for-colour-analog-photo-printing/

  • All
  • Subscribed
  • Moderated
  • Favorites
  • anitta
  • everett
  • magazineikmin
  • Youngstown
  • thenastyranch
  • rosin
  • slotface
  • ngwrru68w68
  • Durango
  • PowerRangers
  • kavyap
  • cisconetworking
  • tsrsr
  • DreamBathrooms
  • modclub
  • mdbf
  • tacticalgear
  • khanakhh
  • ethstaker
  • vwfavf
  • InstantRegret
  • tester
  • osvaldo12
  • cubers
  • GTA5RPClips
  • Leos
  • normalnudes
  • provamag3
  • All magazines