#include "MD_MAX72xx.h"
#define CLK_PIN 52
#define DATA_PIN 51
#define CS_PIN 53
boolean isPushed = false;
int foodButton =A4;
int playButton= A5;
int cleanButton= A3;
boolean screenImage[10][8][8] = {
// Screen 0 - first frame of idle floating
{{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}},
//Screen 1- second frame of idle floating
{{0, 0, 0, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}},
//Screen 2- third frame of idle floating
{{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0}},
//Screen 3-first frame of shrimp feeding
{{1, 1, 1, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0}},
//Screen 4- second frame of shrimp feeding
{{0, 0, 1, 1, 0, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 0},
{1, 0, 0, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0}},
//Screen 5- first frame of dolphin playing with ball
{{0, 0, 0, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0, 1, 0},
{0, 0, 0, 0, 0, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 1, 0}},
//Screen 6- second frame of dolphin playing with ball
{{1, 0, 1, 0, 1, 0, 0, 0},
{0, 1, 0, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0, 1},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 1, 0}},
//Screen 7-third frame of dolphin playing with ball
{{0, 0, 0, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 1, 0, 0, 1, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0}},
//Screen 8-first frame of dolphin being dirty and needing to be cleaned
{{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 0, 0, 1, 1, 0},
{0, 1, 1, 0, 0, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}},
//Screen 9-second frame of dolphin cleaning
{{0, 0, 0, 1, 0, 1, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 1, 1, 1, 0, 0},
{1, 0, 1, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 0}}
};
MD_MAX72XX ledMatrix = MD_MAX72XX(MD_MAX72XX::PAROLA_HW, CS_PIN, 1);
void setup() {
ledMatrix.begin();
pinMode(foodButton,INPUT_PULLUP);
pinMode(playButton, INPUT_PULLUP);
pinMode(cleanButton, INPUT_PULLUP);
}
void loop() {
//idleFloating();
//needsFood();
//playsWithBall();
//needsCleaning();
long randomValue= random(1,4);
Serial.println(randomValue);
delay(500);
}
void frameSelect (int frameNumber){
for (int row= 0; row<=7; row ++){
for(int col= 0; col <=7; col ++){
ledMatrix.setPoint(row, col, screenImage[frameNumber][row][7 - col]);
}
}
}
void idleFloating(){
do{
for(int idlePhase = 0; idlePhase <= 2; idlePhase ++){
frameSelect(idlePhase);
delay(1000);
}
} while(true);
}
void needsFood(){
boolean foodButtonstate;
do{
for(int foodPhase = 3; foodPhase <= 4; foodPhase ++){
frameSelect(foodPhase);
foodButtonstate = digitalRead(A4);
delay(1000);
}
} while(foodButtonstate == isPushed);
}
void playsWithBall(){
do{
for(int ballPhase = 5; ballPhase <= 7; ballPhase ++){
frameSelect(ballPhase);
delay(1000);
}
}while(true);
}
void needsCleaning(){
do{
for(int cleaningPhase = 8; cleaningPhase <= 9; cleaningPhase ++){
frameSelect(cleaningPhase);
delay(1000);
}
} while(true);
}