Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.

32x32 RGB Minecraft
Moderators: adafruit_support_bill, adafruit

32x32 RGB Minecraft

by jillesdotcom on Wed Dec 26, 2012 9:29 pm

Had some fun coding the 32x32 RGB matrix on the arduino this Christmas ;-)

http://www.flickr.com/photos/jillesdotc ... hotostream
http://www.flickr.com/photos/jillesdotc ... hotostream
http://www.flickr.com/photos/jillesdotc ... hotostream
http://www.flickr.com/photos/jillesdotc ... hotostream

I rewrote the RGB (de)coding functions and created some constants to color a bit easier.

rgbcolor() uses seperate codes for red, green & blue e.g. 0..255 or 0x00..0xff
htmlcolor() uses a single (HTML) colorcode, e.g. 0xFF00FF

Code: Select all | TOGGLE FULL SIZE
#include <RGBmatrixPanel.h>

#include <Adafruit_GFX.h>
#include <avr/pgmspace.h>

#define CLK 8 
#define OE  9
#define LAT 10
#define A   A0
#define B   A1
#define C   A2
#define D   A3

RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);

const word black             = 0;
const word white             = 65535;
const word red               = 63488;
const word darkred           = 30720;
const word green             = 31;
const word darkgreen         = 7;
const word blue              = 2016;
const word darkblue          = 992;
const word cyan              = 2047;
const word darkcyan          = 1007;
const word purple            = 31712;
const word yellow            = 63519;
const word pink              = 65504;
const word gray              = 48631;
const word darkgray          = 14823;
const word orange            = 63494;
const word darkorange        = 36870;
const word brown             = 24582;
const word olive             = 30735;
const word violet            = 36390;
const word salmon            = 62290;         
 
void steve() {
  word Eyes=blue;
  word Skin=salmon;
  word Hair=black;
  word Mouth=black;
  word Nose=brown;
  int x,y,l,h=4;
 
  x=0; y=0;
  l=32; matrix.fillRect( x, y,l, h, Hair ); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y,l, h, Hair ); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Hair ); x+=l;
  l=24; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Hair ); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, white ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, white ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l=12; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Nose ); x+=l;
  l=12; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Mouth ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Mouth ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l=16; matrix.fillRect( x, y, l, h, Mouth ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;
}
 
void herobrine() {
  word Eyes=white;
  word Skin=salmon;
  word Hair=black;
  word Mouth=brown;
  word Nose=black;
  int x,y,l,h=4;
 
  x=0; y=0;
  l=32; matrix.fillRect( x, y,l, h, Hair ); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y,l, h, Hair ); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Hair ); x+=l;
  l=24; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Hair ); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, white ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, white ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l=12; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Nose ); x+=l;
  l=12; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l=16; matrix.fillRect( x, y, l, h, Mouth ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y, l, h, Skin); x+=l;

}

void creeper() {
  word Eyes=black;
  word Skin=darkgreen;
  int x,y,l,h=4;
 
  x=0; y=0;
  l=32; matrix.fillRect( x, y,l, h, Skin ); x+=l;

  x=0; y+=h; h=8;
  l= 4; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Eyes ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Eyes ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Skin ); x+=l;

  x=0; y+=h; h=4;
  l=12; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Eyes ); x+=l;
  l=12; matrix.fillRect( x, y, l, h, Skin ); x+=l;

  x=0; y+=h;h=8;
  l= 8; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l=16; matrix.fillRect( x, y, l, h, Eyes ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin ); x+=l;

  x=0; y+=h; h=4;
  l= 8; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Eyes ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Eyes ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin ); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y,l, h, Skin ); x+=l;


void skeleton() {
  word Eyes=black;
  word Skin=gray;
  word Hair=darkgray;
  word Mouth=black;
  word Nose=darkgray;
  int x,y,l,h=4;
 
  x=0; y=0;
  l=32; matrix.fillRect( x, y,l, h, Hair ); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y,l, h, Hair ); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Hair ); x+=l;
  l=24; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Hair ); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l=12; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Nose ); x+=l;
  l=12; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l=24; matrix.fillRect( x, y, l, h, Mouth ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y, l, h, Skin); x+=l;
}

void zombie() {
  word Eyes=black;
  word Skin=green;
  word Hair=darkgreen;
  word Mouth=green;
  word Nose=darkgreen;
  int x,y,l,h=4;
 
  x=0; y=0;
  l=32; matrix.fillRect( x, y,l, h, Hair ); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y,l, h, Hair ); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Hair ); x+=l;
  l=24; matrix.fillRect( x, y, l, h, Skin ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Hair ); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l=12; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 8; matrix.fillRect( x, y, l, h, Nose ); x+=l;
  l=12; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l=24; matrix.fillRect( x, y, l, h, Mouth ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y, l, h, Skin); x+=l;
}

void pig() {
  word Eyes=black;
  word Skin=salmon;
  word Nose=brown;
  int x,y,l,h=4;
 
  x=0; y=0; h=6;
  l=32; matrix.fillRect( x, y,l, h, black ); x+=l;

  x=0; y+=h; h=4;
  l=32; matrix.fillRect( x, y,l, h, Skin ); x+=l;

  x=0; y+=h; h=4;
  l= 2; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, white ); x+=l;
  l=12; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, white ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Eyes  ); x+=l;
  l= 2; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h; h=4;
  l=32; matrix.fillRect( x, y,l, h, Skin ); x+=l;

  x=0; y+=h; h=4;
  l=10; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Nose ); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Skin); x+=l;
  l= 4; matrix.fillRect( x, y, l, h, Nose ); x+=l;
  l=10; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;
  l=32; matrix.fillRect( x, y, l, h, Skin); x+=l;

  x=0; y+=h;h=6;
  l=32; matrix.fillRect( x, y,l, h, black ); x+=l;

}

word rgbcolor(byte r, byte g, byte b ) {
  word red, green, blue,result;
 
  red=((r / 255)*31);
  green=((g / 255)*31);
  blue=((b / 255)*63);
  result=( (red*2048) + (green) + (blue*32) );
  return result;
}

word htmlcolor( word color ) {
  word red, green, blue, result;
 
  blue=color%256;
  green=((color-blue)%65536)/256;
  red=((color-((green*256)+blue)))/65536;
 
  result=rgbcolor(red, green, blue );
  return result;
}

void setup() {
  matrix.begin();
  matrix.fillRect(0, 0, 8, 8, red);
  matrix.fillRect(8, 0, 8, 8, darkred);
  matrix.fillRect(16, 0, 8, 8, orange);
  matrix.fillRect(24, 0, 8, 8, darkorange);

  matrix.fillRect(0, 8, 8, 8, yellow);
  matrix.fillRect(8, 8, 8, 8, brown);
  matrix.fillRect(16, 8, 8, 8, green);
  matrix.fillRect(24, 8, 8, 8, darkgreen);

  matrix.fillRect(0, 16, 8, 8, blue);
  matrix.fillRect(8, 16, 8, 8, darkblue);
  matrix.fillRect(16, 16, 8, 8, cyan);
  matrix.fillRect(24, 16, 8, 8, darkcyan);

  matrix.fillRect(0, 24, 8, 8, purple);
  matrix.fillRect(8, 24, 8, 8, pink);
  matrix.fillRect(16, 24, 8, 8, darkgray);
  matrix.fillRect(24, 24, 8, 8, white);
  delay(10000);
}

void loop() {
  pig();
  delay(1000);
  zombie();
  delay(1000);
  skeleton();
  delay(1000);
  steve();
  delay(1000);
  herobrine();
  delay(1000);
  creeper();
  delay(1000);
}
jillesdotcom
 
Posts: 7
Joined: Fri Dec 14, 2012 5:52 am

Re: 32x32 RGB Minecraft

by adafruit on Fri Dec 28, 2012 2:58 pm

adorable!

adafruit
 
Posts: 11904
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc