Mini Business Ad on Arduino Board!

by alexuisedmonds11 in Circuits > Arduino

14 Views, 0 Favorites, 0 Comments

Mini Business Ad on Arduino Board!

May 6, 2025 at 5_34 PM(1).jpg

In this project, I created a LED advertisement display using an Arduino board, an SH1106 OLED screen, and a row of LEDs. The LEDs animate from left to right and back to catch attention, while the OLED display shows a custom bitmap—perfect for a mini digital business ad.

I designed this project to both grow my computer science skills and promote my business, Hair by Lexx. Learning how to animate ads and display logos helps boost my brand's visibility in a fun and tech-savvy way!

Supplies

To recreate this project, you’ll need:

  1. Arduino board (Uno, Nano, or Mega)
  2. SH1106 128x64 OLED display
  3. 12 LEDs (adjust as needed)
  4. 220Ω resistors (1 per LED)
  5. Jumper wires
  6. Breadboard (optional, for easier connections)
  7. Computer with Arduino IDE installed

Hardware Setup

OLED Display Wiring

VCC → Arduino 5V

GND → Arduino GND

SCL → Arduino A5

SDA → Arduino A4

LED Wiring

Connect LEDs to Arduino digital pins 2–13.

Use a 220Ω resistor in series with each LED (between the cathode/short leg and GND).

If you're using more or fewer LEDs, update the numLEDs variable in your code accordingly.

Install Required Libraries

In the Arduino IDE:

Go to Sketch > Include Library > Manage Libraries.

Search for and install: U8g2 (for the OLED screen).

Make sure the Wire library is installed (usually comes pre-installed).

Upload the Code

Paste the following code into a new Arduino sketch:

#include <U8g2lib.h>
#include <Wire.h>

// Initialize OLED
U8G2_SH1106_128X64_NONAME_2_HW_I2C display(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

extern const unsigned char bitmap1[] U8X8_PROGMEM;

// Array of bitmaps to display
const unsigned char* bitmaps[] = { bitmap1 };

const int numLEDs = 12;
const int startPin = 2;

void setup() {
Serial.begin(9600);
for (int i = 0; i < numLEDs; i++) {
pinMode(startPin + i, OUTPUT);
}
display.begin();
}

void loop() {
// Scroll LEDs left to right
for (int i = 0; i < numLEDs; i++) {
digitalWrite(startPin + i, HIGH);
delay(200);
digitalWrite(startPin + i, LOW);
}

// Scroll LEDs right to left
for (int i = numLEDs - 1; i >= 0; i--) {
digitalWrite(startPin + i, HIGH);
delay(200);
digitalWrite(startPin + i, LOW);
}

// Display the bitmap
int num_bitmaps = sizeof(bitmaps) / sizeof(bitmaps[0]);
for (int i = 0; i < num_bitmaps; i++) {
display.firstPage();
do {
display.drawXBMP(0, 0, 128, 64, bitmaps[i]);
} while (display.nextPage());
delay(2000); // Show image for 2 seconds
}
}

// Replace with your own bitmap
const unsigned char bitmap1[] U8X8_PROGMEM = {
// Bitmap data here
};

Convert Your Image to Arduino Bitmap

You’ll need to convert your logo or ad image to a format the Arduino can use.

Follow these steps:

  1. Use black and white only (no grayscale).
  2. Stick to bold shapes, icons, or text.
  3. Ideal image size: 128x64 pixels.
  4. Use tools like Canva to design, then export as PNG.
  5. Convert with images2cpp
  6. Upload your PNG.
  7. Set the following:
  8. Width: 128
  9. Height: 64
  10. Output format: Arduino code
  11. Drawing mode: Monochrome
  12. Resize method: Scale to fit or Stretch to fill canvas
  13. Check “Swap” if the image preview looks rotated.
  14. Click Generate Code.
  15. Copy only the contents inside the curly braces { ... }.

Example:

const unsigned char myCustomBitmap[] U8X8_PROGMEM = {
0x00, 0x00, 0xFF, 0x81, 0x81, 0xFF, 0x00, 0x00
};

Add to Your Sketch

Paste the bitmap array below the others in your sketch.

Declare it near the top:

extern const unsigned char myCustomBitmap[] U8X8_PROGMEM;

Add it to the bitmaps[] array:

const unsigned char* bitmaps[] = {
bitmap1,
myCustomBitmap,
// Add more if needed
};

Upload and Run in the Arduino IDE


Go to Tools > Board and select your Arduino model.

Select the correct Port.

Click Upload.

Once uploaded:

LEDs will animate left to right and back.

OLED will display your bitmap for 2 seconds per loop.

Troubleshooting Tips

OLED Issues:

  1. Check all wiring (especially SDA/SCL pins).
  2. Make sure you installed the U8g2 library.
  3. Confirm your display is SH1106, not SSD1306 (they use different drivers).

LED Issues:

  1. Double-check pin assignments and resistor placement.
  2. Make sure numLEDs and startPin match your actual setup.