Minyue Dai's Final Project

From CSclasswiki
Jump to: navigation, search

Proposal

Goal

The goal of this project is to connect Elegoo kit devices on Arduino and run various functions. The detailed tutorial gives clear guidelines for 4 parts of the project:

  1. Connect the 64-LED matrix and let it display my name.
  2. Pick second device and connect it to Arduino with 64-LED matrix and make it works correctly.
  3. Pick a third device and connect it to Arduino with 64-LED matrix and make it works correctly.
  4. Integrate three devices on Arduino logically such that they are combined together for a task.

Based on my experience on Arduino devices, here is my basic plan for this project:

  1. Connect the 64-LED matrix to display "MINYUE" as 1 letter per second, such as "M - I - N - Y - U -E".
  2. Connect a keypad which user could press buttons including numbers 0-9, and let the program prints out the key user presses.
  3. Connect a light sensor and let the program prints out the lightness level it detects every second.
  4. Let the 64-LED matrix displays the lightness level light sensor receives only if user presses number < 5 on the key board.

Plan of Attack

  1. Collect all materials needed in this project from the kit.
  2. Watch videos and tutorials online.
  3. First connect the 64-LED matrix correctly and write the display-name sketch.
  4. Then connect the other two devices and complete the sketch independently.
  5. Try to connect all three devices logically and write sketch to make them work.
  6. Record all steps on wiki and prepare for the online presentation.

Project Result

I would record each step in this project in details, including photos of devices, tutorials as reference, sketches and reflection. Then I would give an online presentation going over my project, which includes a live demo of my circuits.

Materials

Here is a list of all materials I use:

Step 1: 64-LED Matrix

Overview

To use 64-LED Matrix, I would like to display my name "M-I-N-Y-U-E" repeatedly. Here is a list of tutorials and resource I refer to:

  1. Youtube Step-By-Step Tutorial
  2. 64-LED Tutorial with Code
  3. GitHub for Arduino Library LedControl
  4. Online LED Matrix Editor

Schematic

The first step is to draw a schematic.

Result

Then I connect the circuit. I set the waiting interval to be 1000(1s) and here is the photos of the circuit.

Step 2: Keypad

Overview

Then we connect an extra 4x4 Keypad on the above circuit, and here is a list of tutorials and recourse I use:

  1. Official Key Pad Tutorial
  2. Useful Tutorial with Code

Schematic

This schematic is key pad only, but actually it does not affect LED matrix so we can connect both of them.

Result

Here is the result. We connect both devices on Arduino and they work well, and when I press key it is shown on the screen.

Sketch

Here is the sketch working for both devices. Notice that to run it correctly, two libraries should be installed.

/*
  Name on 64-LED Matrix with 4x4 Key Pad
  Minyue Dai

  LConnect both 64-LED Matrix and 4x4 Key Pad. The Matrix
  displays "M-I-N-Y-U-E" repeatedly and it detects any input
  from Key Pad and prints it out.

*/

#include <LedControl.h> // include led control library
#include <Keypad.h> // Include Key Pad

int DIN = 10; // define DIN pin to digital pin 10
int CS =  11; // define CS pin to digital pin 11
int CLK = 12; // define CLK to digital pin 12

byte M[]=   {0xc6,0xc6,0xc6,0xd6,0xfe,0xee,0xc6,0x00}; // c6c6c6d6feeec600
byte I[]=   {0x3c,0x18,0x18,0x18,0x18,0x18,0x3c,0x00}; // 3c18181818183c00
byte N[]=   {0x63,0x63,0x73,0x7b,0x6f,0x67,0x63,0x00}; // 6363737b6f676300
byte Y[]=   {0x18,0x18,0x18,0x3c,0x66,0x66,0x66,0x00}; // 1818183c66666600
byte U[]=   {0x7c,0x66,0x66,0x66,0x66,0x66,0x66,0x00}; // 7c66666666666600
byte E[]=   {0x7e,0x06,0x06,0x3e,0x06,0x06,0x7e,0x00}; // 7e06063e06067e00
LedControl lc=LedControl(DIN,CLK,CS,0);

// Setup for Keypad
const byte ROW = 4; 
const byte COL = 4; 
char keys[ROW][COL] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[ROW] = {2,3,4,5}; 
byte colPins[COL] = {6,7,8,9}; 

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROW, COL );
void setup(){
 Serial.begin(9600);
 lc.shutdown(0,false);       //The MAX72XX is in power-saving mode on startup
 lc.setIntensity(0,5);      // Set the brightness, the maximum is 0,15
 lc.clearDisplay(0);         // and clear the display
}

int delayTime = 1000; // Set the interval for each letter.

int count = 0;  
void loop(){ 
  
    char key = keypad.getKey();
    if (key){
    Serial.println(key);
    }
    switch(count%6){
      case 0: printByte(M); break;
      case 1: printByte(I); break;
      case 2: printByte(N); break;
      case 3: printByte(Y); break;
      case 4: printByte(U); break;
      case 5: printByte(E); break;
    }
    count++;    
    delay(delayTime); 

}

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

Project Log

Wednesday 04-22-2020

Read instruction on class wiki and create the proposal.

Friday 04-24-2020

Go over all tutorials online. Make the materials list.

Monday 04-27-2020

Finish 64-LED part.

Tuesday 04-28-2020

Finish key pad part.

Wednesday 04-29-2020

Collect all photos and draw all schematics.

Thursday 04-30-2020

Edit wiki page for the final project report.