#include <LedControl.h>
int DIN = 10;
int CS = 9;
int CLK = 8;
int SOK = 3;
int br = 13;
LedControl lc = LedControl(DIN, CLK, CS, 0);
void setup() {
pinMode(SOK, INPUT);
pinMode(br, OUTPUT);
lc.shutdown(0, false);
lc.setIntensity(0, 15); //Adjust the brightness maximum is 15
lc.clearDisplay(0);
}
void loop() {
//Facial Expression
byte smile[8] = {0x3C,0x42,0x95,0xA1,0xA1,0x95,0x42,0x3C};
byte sad[8] = {0x3C,0x42,0xA5,0x91,0x91,0xA5,0x42,0x3C};
byte AT[8] = {0x00, 0x67, 0x92, 0x92, 0xF2, 0x92, 0x00, 0x00};
if (digitalRead(SOK) == 1)
{
printByte(smile);
noTone(br);
delay(500);
} else /// =0
{
printByte(sad);
tone(br, 400);
delay(500);
noTone(br);
delay(500);
}
}
void printByte(byte character [])
{
int i = 0;
for (i = 0; i < 8; i++)
{
lc.setRow(0, i, character[i]);
}
}
Comments