Professional Documents
Culture Documents
Matrix 8x8 3
Matrix 8x8 3
search
Buy
Download
Products
o
o
o
o
o
Learning
o
o
o
o
o
Forum
Support
o
o
Blog
LOG IN
SIGN UP
Arduino Forum
> Forum 2005-2010 (read only)
> Hardware
> Interfacing
> Christmas card (arduino, max7221, 8x8 matrix led)
Go Down
Pages: [1]
Topic: Christmas card (arduino, max7221, 8x8 matrix led) (Read 5316 times)Previous
Topic - Next Topic
Tomas123
Newbie
Posts: 3
Karma: 0 [add]
Arduino rocks
Christmas card (arduino, max7221, 8x8 matrix led)
Nov 22, 2010, 07:14 pm Last Edit: Nov 22, 2010, 07:26 pm by tomas123 Reason: 1
This is a Christmas card with an arduino, max7221 and a 8x8 matrix LED.
font.h
Code: [Select]
#include <avr/io.h>
#include <avr/pgmspace.h>
#ifndef FONT_H_
#define FONT_H_
#define MAX_CHARS 59
#define CHAR_OFFSET 0x20
#endif /*FONT_H_*/
Tomas123
Newbie
Posts: 3
Karma: 0 [add]
Arduino rocks
/*
Now we need a LedControl to work with.
***** These pin numbers will probably not work with your hardware *****
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
We have only a single MAX72XX.
*/
LedControl lc=LedControl(12,11,10,1);
void setup() {
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,8);
/* and clear the display */
lc.clearDisplay(0);
}
char message_00[] PROGMEM = " ! MERRY CHRISTMAS AND A HAPPY NEW YEAR ! ";
char message_01[] PROGMEM = " COUNTDOWN...";
char message_02[] PROGMEM = " 5 4 3 2 1 ... BOOM!! ";
#define MAX_MESSAGES 3
//PGM_P PROGMEM messages[] = {
PROGMEM const char *messages[] = {
message_00
,message_01
,message_02
};
//#define MAX_ANIMATIONS 3
Tomas123
Newbie
Posts: 3
Karma: 0 [add]
Arduino rocks
/*
* show_char
* Displays the actual message.
* Scrolls the screen to the left and draws new pixels on the right.
* char stop bit is bit.7
*/
void show_char(const prog_uint8_t string[]) {
uint8_t i;
uint8_t b;
active_char -= CHAR_OFFSET;
char_ptr = 0;
/*
* copy_to_buffer
* Copies the given sprite from PROGMEM to 8x8 LED RAM.
*/
void copy_to_buffer(const prog_uint8_t sprite[8]) {
memcpy_P(screen_mem, sprite, 8);
}
/*
* scroll_animation
* Uses sprite_1 and sprite_2 to draw a simple animation.
* blink=1 : change sprite_1/2 every step // blink=0 : blink only in the
middle
* scroll_speed: factor time for next step
*/
void scroll_animation(const prog_uint8_t sprite_1[8], const prog_uint8_t
sprite_2[8], uint8_t blink) {
uint8_t i,j;
int8_t x,z;
if (x==0) {
//in the middle shift betwenn sprite_1 and sprite_2
for (j=0; j<4;j++) {
copy_to_buffer(sprite_2);
writeArduinoOnMatrix();
delay(ANIMATION_SPEED);
copy_to_buffer(sprite_1);
writeArduinoOnMatrix();
delay(ANIMATION_SPEED);
}
}
}
}
}
/*
* step_animation
* Uses sprite_1 to draw a simple animation.
* size of array
*/
void step_animation(const prog_uint8_t sprite_1[][8], uint8_t size) {
uint8_t i;
for (i = 0; i < size; i++) {
copy_to_buffer(sprite_1[i]); //array: step pointer by 8
writeArduinoOnMatrix();
delay(ANIMATION_SPEED);
}
}
void loop() {
int8_t i,j,k;
while (1) {
for (i = 0; i < 8; i+=2) {
scroll_animation(sprite_xy[i], sprite_xy[(i+1)], 1);
writeArduinoOnMatrix();
delay(750);
}
//3 heart
for (i = 0; i < REPEAT_ANIMATION*3; i++) {
copy_to_buffer(sprite_xy[8]);
writeArduinoOnMatrix();
delay(750);
copy_to_buffer(sprite_xy[9]);
writeArduinoOnMatrix();
delay(750);
}
//4
for (k = 0; k < REPEAT_ANIMATION; k++) {
step_animation(stern1, 8);
for (i = 7; i >= 0; i--) {
copy_to_buffer(stern1[i]);
writeArduinoOnMatrix();
delay(ANIMATION_SPEED);
}
for (j = 0; j < REPEAT_ANIMATION; j++) {
step_animation(stern2, 14);
}
}
//5
for (i = 0; i < REPEAT_ANIMATION; i++) {
step_animation(dancer1, 36);
}
//6
for (i = 0; i < MAX_MESSAGES; i++) {
message_displayed = 0;
while (message_displayed < REPEAT_TEXT) {
show_char((uint8_t*)pgm_read_word(&(messages[i])));
//show_char((prog_uint8_t*)pgm_read_word(&(messages[i])));
writeArduinoOnMatrix();
delay(TEXT_SCROLL_SPEED);
}
}
}
}
p_gabriel
Newbie
Posts: 25
Karma: 0 [add]
Arduino rocks
Go Up
Pages: [1]
Jump to:
NEWSLETTER
Subscribe
©2016 Arduino
Copyright Notice
Contact us