#include "LedControl.h"
LedControl lc=LedControl(12,10,11,1);
const int SW_pin = 2;
const int X_pin = 0;
const int Y_pin = 1;
void setup() {
pinMode(SW_pin, INPUT);
digitalWrite(SW_pin, HIGH);
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
}
void writeSmile() {
byte a[8]={B00000000,B00010000,B00100110,B01000000,B01000000,B00100110,B00010000,B00000000};
lc.setRow(0,0,a[0]);
lc.setRow(0,1,a[1]);
lc.setRow(0,2,a[2]);
lc.setRow(0,3,a[3]);
lc.setRow(0,4,a[4]);
lc.setRow(0,5,a[5]);
lc.setRow(0,6,a[6]);
lc.setRow(0,7,a[7]);
delay(delaytime1);
}
void writeSad() {
byte a[8]={B00000000,B01000000,B00100110,B00100000,B00100000,B00100110,B01000000,B00000000};
lc.setRow(0,0,a[0]);
lc.setRow(0,1,a[1]);
lc.setRow(0,2,a[2]);
lc.setRow(0,3,a[3]);
lc.setRow(0,4,a[4]);
lc.setRow(0,5,a[5]);
lc.setRow(0,6,a[6]);
lc.setRow(0,7,a[7]);
delay(delaytime1);
}
void writeNo() {
byte a[8]={B00000000,B01000010,B00100100,B00011000,B00011000,B00100100,B01000010,B00000000};
lc.setRow(0,0,a[0]);
lc.setRow(0,1,a[1]);
lc.setRow(0,2,a[2]);
lc.setRow(0,3,a[3]);
lc.setRow(0,4,a[4]);
lc.setRow(0,5,a[5]);
lc.setRow(0,6,a[6]);
lc.setRow(0,7,a[7]);
delay(delaytime1);
}
void writeYes() {
byte a[8]={B00000000,B00100000,B01000000,B00100000,B00010000,B00001000,B00000100,B00000000};
lc.setRow(0,0,a[0]);
lc.setRow(0,1,a[1]);
lc.setRow(0,2,a[2]);
lc.setRow(0,3,a[3]);
lc.setRow(0,4,a[4]);
lc.setRow(0,5,a[5]);
lc.setRow(0,6,a[6]);
lc.setRow(0,7,a[7]);
delay(delaytime1);
}
void writeAurora() {
byte a[52]={B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
B00000000,B00000000,B01111110,B00010010,B00010010,B01111110,
B00000000,B00000000,B01111110,B01000000,B01000000,B01111110,
B00000000,B00000000,B01111110,B00011010,B00101010,B01001110,
B00000000,B00000000,B01111110,B01000010,B01000010,B01111110,
B00000000,B00000000,B01111110,B00011010,B00101010,B01001110,
B00000000,B00000000,B01111110,B00010010,B00010010,B01111110,
B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};
for(int j=0; j<1; j+=1) {
for(int i=0; i<=44; i+=1) {
lc.setRow(0,0,a[i]);
lc.setRow(0,1,a[i+1]);
lc.setRow(0,2,a[i+2]);
lc.setRow(0,3,a[i+3]);
lc.setRow(0,4,a[i+4]);
lc.setRow(0,5,a[i+5]);
lc.setRow(0,6,a[i+6]);
lc.setRow(0,7,a[i+7]);
delay(100);
}
}
}
int del = 200;
void loop() {
if(analogRead(X_pin) < 100) {
writeSad();
delay(del);
}
if(analogRead(X_pin) > 900) { //up
writeSmile();
delay(del);
}
if(analogRead(Y_pin) > 900 && analogRead(X_pin) > 100 && analogRead(X_pin) < 900) { //dx
writeYes();
delay(del);
}
if(analogRead(Y_pin) < 100 && analogRead(X_pin) > 100 && analogRead(X_pin) < 900) { //sx
writeNo();
delay(del);
}
if(digitalRead(SW_pin)==LOW) {
writeAurora();
}
}
Commenti