Model RR Conference Room

I wish forum.arduino.cc had a model railroad category... (looks much better on live equipment)

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "bitmap.h"

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define BITMAP_WIDTH 25
#define BITMAP_HEIGHT 13

int MAXX = SCREEN_WIDTH - BITMAP_WIDTH;
int MAXY = SCREEN_HEIGHT - BITMAP_HEIGHT;

int xMov = 2;
int yMov = 2;
int x = random(SCREEN_WIDTH);
int y = random(SCREEN_HEIGHT);

Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(9600);

  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {  // 0x3c = 128x64?
    Serial.println(F("SSD1306 allocation failed"));
    while (true) {};
  }
}

void loop() {
  bounce();
}

void bounce() {
  if (x <= 0 || x >= MAXX)
    xMov = -xMov;

  if (y <= 0 || y >= MAXY)
    yMov = -yMov;

  x += xMov;
  y += yMov;

  oled.clearDisplay();
  oled.drawBitmap(x, y, myBitmap, BITMAP_WIDTH, BITMAP_HEIGHT, WHITE);
  oled.display();
}

bitmap.h

// 'dvdx', 25x13px
const unsigned char myBitmap [] PROGMEM = {
	0xff, 0xff, 0xff, 0x80, 0xe0, 0x1f, 0x03, 0x80, 0xfe, 0x0e, 0x7c, 0x80, 0xce, 0x4c, 0x9c, 0x80, 
	0xce, 0x69, 0x9c, 0x80, 0xcc, 0xe3, 0x99, 0x80, 0x83, 0xe7, 0x07, 0x80, 0xff, 0xff, 0xff, 0x80, 
	0xff, 0xff, 0xff, 0x80, 0xe6, 0xb6, 0xe7, 0x80, 0x86, 0xbe, 0xe1, 0x80, 0xfe, 0x82, 0xff, 0x80, 
	0xff, 0xff, 0xff, 0x80
};

What has this topic got to do with model railroads, E-Textiles or Craft ?

Model railroads are a craft. The Bouncing DVD emblem is known throughout all conference rooms. Making a small conference room would need one.

1 Like

??? somehow I don't get it ...

Ok ... Now let's move to N scale :slight_smile:

It's running on my 128x32 OLED

A two minutes video demonstration:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.