How to draw circles and lines with Arduboy Library?

Im trying to draw a circle on my Arduboy and I don’t know if its possible to draw it with the default Arduboy Library.

I think its possible, isn’t it?

Yes. Lines, circles, rectangles, triangles, rectangles with rounded corners, and filled versions of the shapes.

Both the Arduboy library and the Arduboy2 library have the same drawing functions but I suggest you use Arduboy2 so you can refer to its more extensive documentation.

Here’s a simple sketch that will just draw a circle with a 10 pixel radius at the centre of the screen (over and over):

#include <Arduboy2.h>

Arduboy2 arduboy;

void setup() {

void loop() {
  arduboy.clear(); // Clear the screen buffer
  // Draw a circle centred at 63 pixels across and 31 pixels down
  // with a radius of 10 pixels
  // using colour WHITE to set the pixels on
  arduboy.drawCircle(63, 31, 10, WHITE);
  arduboy.display(); // Display the contents of the screen buffer  

What about a line?
I use your Library

Please refer to the documentation. There is drawLine(), drawFastHLine() and drawFastVLine().

1 Like

Thanks, your library help me to make this little example: GitHub

1 Like

Next, you may wish to change your sketch to use the library frame functions, to run the sketch at a constant frame rate, instead of using delay() to slow things down.

In setup() after; add line:

  arduboy.setFrameRate(30); // Run at 30 frames per second

At the start of loop(), before arduboy.clear() add:

  // Wait until it's time for the next frame
  if (!arduboy.nextFrame())

Delete the delay(35); line near the end of loop()

Now your sketch will run at a constant 30 frames per second. You don’t have to use delay(), which you would need to keep adjusting as you add more code. You can change the frame rate to something other than 30 if you wish, to speed up or slow down the sketch.

1 Like

Thanks, like this?

Yes, that is correct. :smile: