Difference between revisions of "User:270o"
(→Part 3: Combining Part 1 and Part 2) |
(→Sketch) |
||
Line 35: | Line 35: | ||
===Sketch=== | ===Sketch=== | ||
+ | <source lang="C"> | ||
+ | /* | ||
+ | * Lizette Carpenter | ||
+ | * Part 64-LED Matrix and Arduino Configuration | ||
+ | * The 64-LED Matrix will display my name: "L I Z E T T E" | ||
+ | * | ||
+ | * References: | ||
+ | * LED Control library: | ||
+ | * Google Chrome app: LED Byte Generator | ||
+ | */ | ||
+ | |||
+ | //Include the following library | ||
+ | #include <LedControl.h> | ||
+ | |||
+ | //Declare the pins of the Arduino following how it is connected to the pins of the LED Matrix | ||
+ | int DIN = 12; | ||
+ | int CS = 11; | ||
+ | int CLK = 10; | ||
+ | |||
+ | //Declare the byte arrays which represent the letters that will display on the LED Matrix | ||
+ | byte l[8] = {0x0,0x40,0x40,0x40,0x40,0x40,0x7e,0x0}; | ||
+ | byte i[8] = {0x0,0x8,0x8,0x8,0x8,0x8,0x8,0x0}; | ||
+ | byte z[8] = {0x0,0x7e,0x4,0x8,0x10,0x20,0x7e,0x0}; | ||
+ | byte e[8] = {0x0,0x7c,0x40,0x7c,0x40,0x40,0x7c,0x0}; | ||
+ | byte t[8] = {0x0,0x7f,0x8,0x8,0x8,0x8,0x8,0x0}; | ||
+ | byte T[8] = {0x0,0x0,0xfe,0x10,0x10,0x10,0x10,0x10}; | ||
+ | |||
+ | |||
+ | //Initialize the LED control library | ||
+ | LedControl lc=LedControl(DIN, CLK, CS, 0); | ||
+ | |||
+ | void setup() { | ||
+ | lc.shutdown(0, false); | ||
+ | lc.setIntensity(0,15); | ||
+ | lc.clearDisplay(0); | ||
+ | |||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | printByte(l); | ||
+ | delay(1000); | ||
+ | |||
+ | printByte(i); | ||
+ | delay(1000); | ||
+ | |||
+ | printByte(z); | ||
+ | delay(1000); | ||
+ | |||
+ | printByte(e); | ||
+ | delay(1000); | ||
+ | |||
+ | printByte(t); | ||
+ | delay(1000); | ||
+ | |||
+ | printByte(T); | ||
+ | delay(1000); | ||
+ | |||
+ | printByte(e); | ||
+ | delay(1000); | ||
+ | } | ||
+ | |||
+ | //Loops through each byte array and displays its corresponding letter to the LED Matrix. | ||
+ | void printByte(byte character []) { | ||
+ | int i = 0; | ||
+ | for (i = 0; i<8; i++) { | ||
+ | lc.setRow(0, i, character[i]); | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
=Part 2: i2c link between Raspberry Pi to the Arduino= | =Part 2: i2c link between Raspberry Pi to the Arduino= |
Revision as of 03:37, 2 May 2020
Contents
Introduction
Welcome to the Wiki Page of my Final Project for CSC270: Digital Circuits Systems. The purpose of this project is to create three configurations using various Elegoo Gadgets including a Mega2560 Arduino, Raspberry Pi and a 64-LED matrix. These configurations will each be able to execute a task as detailed in the outline.
Plan
Outline
The objectives explained in the Introduction will be achieved in 3 parts:
- Connect a 64-LED matrix display to a Mega2560 Arduino and program it to display my name, "L I Z E T T E".
- Demonstrate a master - worker model by establishing an i2c link between a Raspberry Pi and a Mega2560 Arduino. The Raspberry Pi will send a word to the Arduino. The Arduino will implement a Atbash Cipher on the word, then send it back to the Raspberry Pi.
- Retrieve Seattle, Washington's current weather from weather.com using a Raspberry Pi. The Raspberry Pi will send it to the Arduino, which will display the data on the 64-LED matrix display.
I will be programming the Raspberry Pi and Arduino in C.
Materials
- Mega2560 Arduino
- Raspberry Pi 3
- 64-LED Matrix
- Breadboard
- Wires
- Resistors
Resources
Part 1: Connect and Program 64-LED matrix to Arduino
Summary
Images & Videos
Sketch
/*
* Lizette Carpenter
* Part 64-LED Matrix and Arduino Configuration
* The 64-LED Matrix will display my name: "L I Z E T T E"
*
* References:
* LED Control library:
* Google Chrome app: LED Byte Generator
*/
//Include the following library
#include <LedControl.h>
//Declare the pins of the Arduino following how it is connected to the pins of the LED Matrix
int DIN = 12;
int CS = 11;
int CLK = 10;
//Declare the byte arrays which represent the letters that will display on the LED Matrix
byte l[8] = {0x0,0x40,0x40,0x40,0x40,0x40,0x7e,0x0};
byte i[8] = {0x0,0x8,0x8,0x8,0x8,0x8,0x8,0x0};
byte z[8] = {0x0,0x7e,0x4,0x8,0x10,0x20,0x7e,0x0};
byte e[8] = {0x0,0x7c,0x40,0x7c,0x40,0x40,0x7c,0x0};
byte t[8] = {0x0,0x7f,0x8,0x8,0x8,0x8,0x8,0x0};
byte T[8] = {0x0,0x0,0xfe,0x10,0x10,0x10,0x10,0x10};
//Initialize the LED control library
LedControl lc=LedControl(DIN, CLK, CS, 0);
void setup() {
lc.shutdown(0, false);
lc.setIntensity(0,15);
lc.clearDisplay(0);
}
void loop() {
printByte(l);
delay(1000);
printByte(i);
delay(1000);
printByte(z);
delay(1000);
printByte(e);
delay(1000);
printByte(t);
delay(1000);
printByte(T);
delay(1000);
printByte(e);
delay(1000);
}
//Loops through each byte array and displays its corresponding letter to the LED Matrix.
void printByte(byte character []) {
int i = 0;
for (i = 0; i<8; i++) {
lc.setRow(0, i, character[i]);
}
}