21 October 2019

Communicate Your Feelings




             

For this project, I used the membrane keypad and the LED dot matrix to convey emotion. When you press buttons 1 through 9 randomly on the keypad, you will see 1 of 4 sketches on the LED dot matrix: happy face, sad face, neutral face and an alien. If you go into the serial monitor, you will be able to see the corresponding phrase that goes with each emoji.

Materials Used:

LED Dot Matrix
Membrane Keypad
Jumper Wires
Arduino









#include <MaxMatrix.h>
#include <Keypad.h>
#include <LedControl.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
int DIN = 12;
int CS = 11;
int CLK = 10;
int maxInuse = 1;
LedControl lc=LedControl(10,11,12);
/* we always wait a bit between updates of the display */
unsigned long delaytime=50;
MaxMatrix m(DIN, CS, CLK, maxInuse);
//char happy[8]= {B00111100,B01000010,B00111100,B01000010,B10100101,B10000001,B10100101,B10011001};
char happy[8]= {B00111100,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100};
char neutral[8]={B00111100, B01000010,B10100101,B10000001,B10111101,B10000001,B01000010,B00111100};
char sad[8]= {B00111100,B01000010,B10100101,B10000001,B10011001,B10100101,B01000010,B00111100};
char alien[8] ={B00100100,B00100100,B01111110,B11011011,B11111111,B11111111,B10100101,B00100100};
byte biglove[] = {8,8, 0x0,0x66,0xFF,0xFF,0xFF,0x7E,0x3C,0x18,};
byte hashtag[]= {8,8,0x24,0x24,0xFF,0x24,0x24,0xFF,0x24,0x24};
byte astrik[]= {8,8,0x81,0x42,0x24,0x18,0xFF,0x24,0x42,0x81};
void setup(){
m.init(); // MAX7219 initialization
m.setIntensity(8); // initial led matrix intensity, 0-15
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();
//Keys pressed should match a picture of the word typed.
if(Serial.available() > 0) {
char c = Serial.read();
Serial.println(c);
if(c == '1'){
m.writeSprite(0, 0, biglove);
Serial.println("Love and Happiness");
}
if(c == '2'){
m.writeSprite(0, 0, astrik);
Serial.println("Seeing Stars");
}
if(c == '3'){
m.writeSprite(0, 0, hashtag);
Serial.println("#physicalcomputingdreamteam");
}
}
if(customKey == '1'){
m.writeSprite(-6, 0, sad);
delay(1000);
Serial.println("Being sad is no fun!");
}
if(customKey == '2'){
m.writeSprite(-6, 0, alien);
delay(1000);
Serial.println("Take me to your mother ship!");
}
if(customKey == '3'){
m.writeSprite(-6, 0, neutral);
delay(1000);
Serial.println("Comme ci comme ça!");
}
if(customKey == '4'){
m.writeSprite(-6, 0, alien);
delay(1000);
Serial.println("Take me to you mother ship!");
}
if(customKey == '5'){
m.writeSprite(-6, 0, happy);
delay(1000);
Serial.println("Happiness is the key!");
}
if(customKey == '6'){
m.writeSprite(-6, 0, sad);
delay(1000);
Serial.println("Being sad is no fun!");
}
if(customKey == '7'){
m.writeSprite(-6, 0, alien);
delay(1000);
Serial.println("Take me to your mothership!");
}
if(customKey == '8'){
m.writeSprite(-6, 0, happy);
delay(1000);
Serial.println("Happiness is the key!");
}
if(customKey == '9'){
m.writeSprite(-6, 0, neutral);
delay(1000);
Serial.println("Comme ci comme ça!");
}
}
view raw Communications hosted with ❤ by GitHub

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.