Eleanor's Final Project

From CSclasswiki
Revision as of 16:04, 5 May 2020 by 270m (talk | contribs)
Jump to: navigation, search

Project Proposal

I am choosing to do the Arduino only option. My project idea is to utilize the 8x8 grid and the joystick to create the game Snake, and for Part 3 to use the 8x8 grid, the joystick, and the button to recreate space invaders.

Part 1: Name Print

The name printing aspect was a fairly straightforward introduction to using the 8x8 LED screen

Helpful Links

Video Tutorial with links to example code: https://www.youtube.com/watch?v=TOuKnOG8atk

Code

#include <LedControl.h>

int DIN = 12;
int CS =  11;
int CLK = 10;

//obtained binary letter values from : https://create.arduino.cc/projecthub/SAnwandter1/programming-8x8-led-matrix-23475a
byte A[] = {  B00000000,B00111100,B01100110,B01100110,B01111110,B01100110,B01100110,B01100110};
byte E[] = {B00000000,B00111100,B00100000,B00111000,B00100000,B00100000,B00111100,B00000000};
byte L[] = {B00000000,B00100000,B00100000,B00100000,B00100000,B00100000,B00111100,B00000000};
byte R[] = {B00000000,B00111000,B00100100,B00100100,B00111000,B00100100,B00100100,B00000000};
byte N[] = {B00000000,B00100010,B00110010,B00101010,B00100110,B00100010,B00000000,B00000000};
byte O[] = {B00000000,B00111100,B01000010,B01000010,B01000010,B01000010,B00111100,B00000000};


LedControl lc=LedControl(DIN,CLK,CS,0);

void setup(){
 lc.shutdown(0,false);       //The MAX72XX is in power-saving mode on startup
 lc.setIntensity(0,15);      // Set the brightness to maximum value
 lc.clearDisplay(0);         // and clear the display
}

void loop(){ 

    printByte(E);
     
    delay(1000);

    printByte(L);
    
    delay(1000);

    printByte(E);    

    delay(1000);
   
    printByte(A);    

    delay(1000);
    printByte(N);    

    delay(1000);
    printByte(O);    

    delay(1000);
    printByte(R);    

    delay(1000);
   
    lc.clearDisplay(0);
    
    delay(1000);
}


void printByte(byte character [])
{
  int i = 0;
  for(i=0;i<8;i++)
  {
    lc.setRow(0,i,character[i]);
  }
}