Welcome, Guest
Username: Password: Remember me

TOPIC: Space Invader Display Test

Space Invader Display Test 4 months 2 weeks ago #1854

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 695
  • Thank you received: 146
  • Karma: 41
This is a short code that just represents some images on the four 8x8 displays. You can use it to test your screen and to learn how to represent "bitmaps" using the
lc.setRow
function,

/*
This is a simple code that show some graphics on the Arduino Audio Meter
you can lear how to represent bitmaps with it, each monster address a diferent 8x8display (0 to 3)
*/
 
#include "LedControl.h"

LedControl lc=LedControl(12,11,10,4); // lc is our object
 
int monster1[8]={
    B00011000,
    B00111100,
    B01111110,
    B01011010,
    B01111110,
    B00100100,
    B01011010,
    B00000000};
 
    int monster2[8]={
    B00100100,
    B00100100,
    B01111110,
    B01111110,
    B11011011,
    B11111111,
    B10100101,
    B00000000};
 
    int monster3[8]={
    B00100100,
    B00100100,
    B01111110,
    B01011010,
    B01011010,
    B01111110,
    B10100101,
    B10100101};
 
    int monster4[8]={
    B00011000,
    B00111100,
    B01111110,
    B11011011,
    B01111110,
    B00111100,
    B00011000,
    B00011000};
 
void setup(){
//init the four 8x8 displays
  lc.shutdown(0, false);
  lc.setIntensity(0, 14);
  lc.clearDisplay(0);
 
  lc.shutdown(1, false);
  lc.setIntensity(1, 14);
  lc.clearDisplay(1);
 
  lc.shutdown(2, false);
  lc.setIntensity(2, 14);
  lc.clearDisplay(2);
 
  lc.shutdown(3, false);
  lc.setIntensity(3, 14);
  lc.clearDisplay(3);
}
 
 
void loop(){
lc.setRow(0,0,monster1[0]);
lc.setRow(0,1,monster1[1]);
lc.setRow(0,2,monster1[2]);
lc.setRow(0,3,monster1[3]);
lc.setRow(0,4,monster1[4]);
lc.setRow(0,5,monster1[5]);
lc.setRow(0,6,monster1[6]);
lc.setRow(0,7,monster1[7]);
 
lc.setRow(1,0,monster2[0]);
lc.setRow(1,1,monster2[1]);
lc.setRow(1,2,monster2[2]);
lc.setRow(1,3,monster2[3]);
lc.setRow(1,4,monster2[4]);
lc.setRow(1,5,monster2[5]);
lc.setRow(1,6,monster2[6]);
lc.setRow(1,7,monster2[7]);
 
lc.setRow(2,0,monster3[0]);
lc.setRow(2,1,monster3[1]);
lc.setRow(2,2,monster3[2]);
lc.setRow(2,3,monster3[3]);
lc.setRow(2,4,monster3[4]);
lc.setRow(2,5,monster3[5]);
lc.setRow(2,6,monster3[6]);
lc.setRow(2,7,monster3[7]);
 
lc.setRow(3,0,monster4[0]);
lc.setRow(3,1,monster4[1]);
lc.setRow(3,2,monster4[2]);
lc.setRow(3,3,monster4[3]);
lc.setRow(3,4,monster4[4]);
lc.setRow(3,5,monster4[5]);
lc.setRow(3,6,monster4[6]);
lc.setRow(3,7,monster4[7]);
}


File Attachment:

File Name: space_invader_display_test.zip
File Size: 6 KB



space_invider.jpg
Last Edit: 4 months 1 week ago by Ray.
The administrator has disabled public write access.
Time to create page: 0.346 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio