Running arduino pins

Good to know, thank you!

The Arduboy’s RGB LED is common anode, which is wired to Vcc. Therefore, you have to pull the cathodes low to light its LEDs. This means in digital mode LOW will light the LED and HIGH will turn it off. In analogue mode a 255 will be off and 0 will be fully on.

The Arduboy2 library functions and defines compensate for this inversion if used as documented.

As for the audio enable/disable being reversed, that makes no sense to me.

@Mr.Blinky I’m looking through the library and pin assignments to try to just re-map the speaker pin 2 to Arduino Micro pin 3(pwm) for “pro Micro 5v - Standard wiring” but I can’t find where the actual pin is assigned for audio ( either TONE_PIN_PORT, TONE_PIN, or SPEAKER_2_DDR, SPEAKER_2_BIT

Do you know where I could find these, or is this process going to be way over my head?

Thank you

If you look inside

…/.arduino15/packages/arduboy-homemade/hardware/avr/1.2.9/libraries/Arduboy2/src

Here you should see this file among others:

Arduboy2Core.h

Open “Arduboy2Core.h” in your favorite text editor and look at lines 187-203 for the speaker pin port defines, and edit them to your liking. Make sure you are using the correct port labels in your define or it will not work. Save the file, exit.

These defines are referenced by “Arduboy2Audio.cpp” to initialize the pins. If you want to know how that works as well, it’s a pretty small file and fairly self-explanatory, so it’s a short read.

Awesome, thanks! I totally overlooked that.
so

#define PIN_SPEAKER_2 13 /**< The pin number of the second lead of the speaker */
#define SPEAKER_2_PORT PORTC
#define SPEAKER_2_DDR DDRC
#define SPEAKER_2_BIT PORTC7

Becomes

#define PIN_SPEAKER_2 3 /**< The pin number of the second lead of the speaker */
#define SPEAKER_2_PORT PORTD
#define SPEAKER_2_DDR DDRD
#define SPEAKER_2_BIT PORTD0

Would you happen to know if that’s right?

@thatringokid, just to let you know, I’ve edited the code you posted into code blocks.

You may want to have a quick read of this thread:

It explains how to use code blocks, among other things.

@Pharap sorry! Thanks

1 Like

Looks good! I don’t know if you plan to make changes to any other pins but if so I’d keep the Arduino PortManipulation page tabbed, even if you’re familiar it’s good for reference to be certain. A pinout sheet of the pro micro or just the atmega32u4 that includes ports in its key is also handy, i.e., this one:

1 Like

Nice! Wasn’t sure what the DDR bit did exactly.
Good tip on the chart, i don’t ever deal with the ports directly so I’ll def take that

DDR is explained more in-depth in that Port Manipulation page I linked, but basically it tells the microcontroller what the assigned port is being used as. So there’s DDRA, DDRB, DDRC, and DDRD, each corresponding to either a read or write mode (input vs. output) and a range of either the digital or analog pins. So in your case, it was DDRC first because it was being used as an output on pin 13, but now that it’s set to pin 3, it needs to be DDRD, as D is the indicator for digital pins 0-7 (typically. again, a pinout or datasheet of the atmega32u4 is your best friend here.)

2 Likes

Makes sense. Thanks so much

1 Like

:confused: I don’t think the timer is the same on that pin or something. Beep2 doesn’t seem to work.

Assigned the to BeepPin2, began it, started the timer. Ran it the same way I would run pin1.
Pin1 works, Pin 2 does not

rumble.tone(rumble.freq(659.255), 50);

The BeepPin classes in the Arduboy2 library each use a timer/counter to generate the frequencies. Each timer/counter can only control certain pins.

Speaker Pin 1 is on Arduino Pin 5, which is Port C6. The BeepPin1 class uses timer/counter 3A to generate the tones on this pin.

Speaker Pin 2 is on Arduino Pin 13, which is Port C7. The BeepPin2 class uses timer/counter 4A to generate the tones on this pin.

If you wanted to reassign Speaker Pin 2 to Arduino Pin 3 (Port D0), you would have to use timer/counter 0B because it’s the only one capable of controlling this pin. However, timer/counter 0 is used as the main system timer, so you may run into difficulties trying to use it as a BeepPin frequency generator.

The Arduboy speaker pins were specifically chosen with consideration to which timer/counters were able to control them.

@MLXXXp yea i was looking around in the library and found the timer, just wasn’t sure which other options i had and if they would be the same interval as beepin1 or what 2 was supposed to be. Ill have to look into it tomorrow, i figured there was a reason it wasn’t just put on pin 3. I may just make my life easier and switch to a full sized Leonardo. Thanks for the info

I used an Arduino Micro for my breadboard system, the drawback being that the TX and RX LEDs are reverse polarity to an Arduboy or Leonardo. This isn’t a problem if you compile the sketches for an Arduino Micro.

This guide by @Mr.Blinky is useful for selecting a board:

3 Likes

I hadn’t see that image before but its really clear and should help a lot of newbies.

1 Like

I wish I could find the “big chip” from that list. Looks like the best of both worlds

It looks like that’s just a Pro Micro with a bit of… well I’m not sure what you’d call it, but it’s essentially just a bit of extra circuit board stuck to the end.

Something like this:

And then they’ve just sliced a chunk off and glued it on to the board.

The wires are soldered to the legs of the CPU to link up to the extra pins that can’t be accessed with the standard or alternate wiring arrangements.

The Sparkfun Pro Micro and most clones use the ATmega32U4 in the QFN package. It is very difficult to solder directly to the QFN package pins to bring them out.

The “big chip” Pro Micro uses an ATmega32U4 in the TQFP package. Although still not easy for some, soldering wires to the pins of a TQFP package is quite a bit easier than a QFN package.

If you look at the photo of the Arduino Leonardo in the referenced image, you’ll see that the ATmega32U4 is a QFN package but is surrounded by pads to accept a TQFP package. You can use this as a size comparison.

3 Likes

@Pharap this^ i don’t think i could solder the tinyness of the regular pro micro chip.