Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Code for print the numbers from 0 to 99 Colorduino http://zygzax.com/
- #include <Colorduino.h>
- void setup()
- {
- Colorduino.Init(); //We startup Colorduino
- // White Balance Calibration RGB
- unsigned char whiteBalVal[3] = {36,63,63};
- Colorduino.SetWhiteBal(whiteBalVal);
- }
- //CHARACTERS---------------------
- byte numbers[10][6][4]={
- {{0,1,1,0},{1,0,0,1},{1,0,0,1},{1,0,0,1},{1,0,0,1},{0,1,1,0}},
- {{0,0,1,0},{0,1,1,0},{0,0,1,0},{0,0,1,0},{0,0,1,0},{0,1,1,1}},
- {{0,1,1,0},{1,0,0,1},{0,0,0,1},{0,0,1,0},{0,1,0,0},{1,1,1,1}},
- {{1,1,1,1},{0,0,1,0},{0,1,0,0},{0,0,1,0},{1,0,0,1},{0,1,1,1}},
- {{0,0,0,1},{0,0,1,1},{0,1,0,1},{1,1,1,1},{0,0,0,1},{0,0,0,1}},
- {{1,1,1,1},{1,0,0,0},{1,1,1,0},{0,0,0,1},{1,0,0,1},{0,1,1,0}},
- {{0,0,1,1},{0,1,0,0},{1,0,0,0},{1,1,1,1},{1,0,0,1},{0,1,1,0}},
- {{1,1,1,1},{0,0,0,1},{0,0,1,0},{0,1,0,0},{1,0,0,0},{1,0,0,0}},
- {{0,1,1,0},{1,0,0,1},{0,1,1,0},{1,0,0,1},{1,0,0,1},{0,1,1,0}},
- {{0,1,1,0},{1,0,0,1},{0,1,1,1},{0,0,0,1},{0,0,1,0},{0,1,0,0}},
- };
- byte error[6][8]={{0,0,0,0,0,0,0,0},{1,1,1,0,1,1,1,0},{1,0,0,0,1,0,0,1},{1,1,1,0,1,1,1,0},{1,0,0,0,1,0,1,0},{1,1,1,0,1,0,0,1}};
- //CHARACTERS END-------------------
- //FUNCTIONS------------------------
- //Print an array 3x8x8 (RGB,Rows,Columns)
- void PrintMatrix(int data[3][8][8]){
- int f,c;
- for(f=0;f<8;f++){
- for(c=0;c<8;c++){
- if(data[0][f][c]>1||data[1][f][c]>1||data[2][f][c]>1){
- Colorduino.SetPixel(f,c,data[0][f][c],data[1][f][c],data[2][f][c]);
- }
- else{
- Colorduino.SetPixel(f,c,0,0,0);
- }
- }
- }
- Colorduino.FlipPage();
- }
- //End of function
- //Change the background color (Run before writing the number)
- void Background(int color[3],int out[3][8][8]){
- int f,c,n;
- for(f=0;f<8;f++){
- for(c=0;c<8;c++){
- for(n=0;n<3;n++){
- out[n][f][c]=color[n];
- }
- }
- }
- }
- //End of function
- //Write a number up to 2 digits
- void Number(int data,int color[3],int out[3][8][8]){
- int f,c,n,u,d;
- if(data>99){
- for(f=0;f<6;f++){
- for(c=0;c<8;c++){
- if(error[f][c]==1){
- for(n=0;n<3;n++){
- out[n][f+1][c]=error[f][c]*color[n];
- }
- }
- }
- }
- }
- else{
- if(data<10){
- for(f=0;f<6;f++){
- for(c=0;c<4;c++){
- if(numbers[data][f][c]==1){
- for(n=0;n<3;n++){
- out[n][f+1][c+2]=numbers[data][f][c]*color[n];
- }
- }
- }
- }
- }
- else{
- u=data%10;
- d=(data-u)/10;
- for(f=0;f<6;f++){
- for(c=0;c<4;c++){
- if(numbers[d][f][c]==1){
- for(n=0;n<3;n++){
- out[n][f+1][c]=numbers[d][f][c]*color[n];
- }
- }
- }
- }
- for(f=0;f<6;f++){
- for(c=0;c<4;c++){
- if(numbers[u][f][c]==1){
- for(n=0;n<3;n++){
- out[n][f+1][c+4]=numbers[u][f][c]*color[n];
- }
- }
- }
- }
- }
- }
- }
- //End of function
- //MAIN FUNCTION---------------
- void loop(){
- int i;
- int color[3]={63,0,10};
- int background[3]={10,63,20};
- int response[3][8][8];
- for(i=0;i<102;i++){
- Background(background,response);
- Number(i,color,response);
- PrintMatrix(response);
- delay(1000);
- }
- }
- //END OF MAIN FUNCTION-----------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement