Touch the buttons

Yes, in our extensive discussion that determined the Arduboy pin mapping, we wanted to make sure at least one button could generate an “official” Arduino handled interrupt and be capable of waking the MCU from power-down mode. For ATmega32U4 based Arduinos, those are pins 0, 1, 2, 3, 7.

Pin 0 is RX
Pin 1 is TX
Pin 2 is SDA
Pin 3 is SCL

It was desirabe to leave these pins free for possible future expansion (which turned out to be good, since the Arduboy Mini is now using SDA and SCL for the Qwiic interface, and serial RX/TX are useful to hackers). That left Pin 7, which was assigned to the A button.

The B button ended up on Arduino Pin 8 (PB4), which can generate a pin change interrupt (PCINT4). Although it’s not assignable to the Arduino attachInterupt() function it can still be utilised through custom code.

1 Like

Interrupt to wake up the micro should be inside the code of all games?

It’s not - it’s up to the developer.

On the Arduboy mini, the microcontroller goes to sleep when the reset button is pressed from within the bootloader.

I don’t use RGB led in arduboy diy.
For me, pins 2, 3, 9, 10 are not connected anywhere.
Can I use it to wake up the micro?
Do I have to change something in the codes?
When the arduboy sleeps, the battery is consumed?

I can’t answer the other two but…

Yes. It consumes less power, but it still draws power to keep the RAM refreshed and the timer(s) running.

As for how much power, I can’t answer that, that’s a job for @MLXXXp or @Mr.Blinky (or at least someone who can read the datasheet and undestands how volts and whatnot work).

1 Like

The on chip RAM is static, so no need to refresh it. If you don’t need timer(s), you can have them shut down.

The deepest sleep mode is power-down. In this mode even the external oscillator is stopped, so the MCU is not clocked. With the best case settings, the MCU would draw under 2µA while still being able to wake it up with a button interrupt. The display can be put to sleep, where it would typically draw about 3µA.

With the Arduboy’s 180mAh battery and total 5µA draw, an Arduboy could sleep for over 4 years but the time would be somewhat shorter due to battery self-discharge.

For the Arduboy FX, the flash chip in power-down mode would typically draw another 1µA, for a total 6µA. It could sleep for about 3 years and 5 months (minus battery self-discharge).


I stand corrected.

Presumably it still draws power to maintain the data though, considering that it’s volatile memory?

1 Like

Only leakage through the very high resistance MOSFET transistors that make up the RAM. It’s part of the overall sleep current draw specified in the datatsheet. (It could be a large percentage of that figure, though.)

The all-knowing web says that a LiPo cell’s self-discharge rate is typically about 5% per month, so a 180mAh battery would self-discharge at a rate of 12.5µA without being connected to anything.

Adding in the 5µA drawn by a sleeping Arduboy, sleep time would be about 1 year and 2 months.

For an Arduboy FX drawing 6µA, it would be a bit less at 1 year and 1.5 months.


Oh good that it needs little current in sleep mode.
But I don’t want him to sleep for a year :slight_smile: :sweat_smile:
Maybe add a simple code that after 30 seconds if the button is not touched, the arduboy will go to sleep and when the button is touched, the arduboy will wake up.
After the game, you release Ardboy and after 30 seconds he falls asleep.
When you return to it, it wakes up with the touch of a button.
If I knew a little bit of coding, I would try to make it.

I’m thinking that we need a simple to use library for the Arduboy that performs sleeping in various modes and waking using the A and/or B button, and/or or the watchdog timer. For the watchdog timer, having the ability to just decrement a counter and only perform the desired action after it reaches 0 would be useful for longer timings.

Unfortunately, I don’t have the time right now (no pun intended) to do this. I could partake in an implementation discussion, though.