While doing stuff like, making our home a little greener. Smoking meat. Working on diorama’s and my Escape game. I found time to make this little maze game.
Using an ESP32, mini joystick and a 8×8 led matrix. The objective is to get to the other side of the invisible maze.
It is a blind maze, so you have to figure out the path by trail and error. I found it quite fun and entertaining. (Coline had a hard time finishing the mode 3 maze)
I’ve got 3 settings on the maze: 0 – There is a trail where you have been. 1 – No trail, but only red leds showing walls. 2 – No trail, red reds and a reset to square 0,0 .. so you have to remember the path you previously took.
I’ll add code and schematics tomorrow …
Light blue shows you where you have been
Mode 2 game, reset when hitting a wall
Hitting the end block!
Maze is static at the moment, i’m planning to implement a “Recursive division method” to generate the maze.
Code
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
// joystick pins
int up=33;
int down=25;
int left=32;
int right=26;
int cursor=32;
// 0 easy = trail // 1 only red walls // 2 = reset to 0.0
int mode=2;
//int trail=32;
int trail=0;
// Which pin on the Arduino is connected to the NeoPixels?
#define LED_PIN 2
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 64
// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// bits set opening in square
// 2
// -----
// 1 | | 4
// -----
// 0
// so 5 is a passage from left to right (1+4)
int maze[8][8] = {
4,5,3,6,5,5,5,3,
6,5,11,12,5,3,6,9,
14,1,12,5,3,10,12,1,
12,5,5,3,10,12,5,3,
2,6,5,9,14,5,1,10,
10,10,6,5,9,6,5,9,
12,11,10,6,1,10,6,1,
4,9,12,13,5,13,13,1,
};
int displaymatrix[8][8] = {
{ 0,1,2,3,4,5,6,7 },
{ 15,14,13,12,11,10,9,8 },
{16,17,18,19,20,21,22,23},
{31,30,29,28,27,26,25,24},
{32,33,34,35,36,37,38,39},
{47,46,45,44,43,42,41,40},
{48,49,50,51,52,53,54,55},
{63,62,61,60,59,58,57,56}
};
int x = 0;
int y = 0;
void setup() {
// joy
pinMode(32, INPUT_PULLUP);
pinMode(33, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
// mode set with jumpers
pinMode(34, INPUT_PULLUP);
pinMode(35, INPUT_PULLUP);
Serial.begin(115200);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
strip.setBrightness(10);
// set begin and end pixel
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.setPixelColor(displaymatrix[7][7], 0, 255, 0);
strip.show();
//mode select
if (digitalRead(34) == 0) {
mode=0;
if (digitalRead(35) == 0) {
mode=2;
} else {
mode=1;
}
// finish effect
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
// reset to start (mode 2)
void reset2start() {
strip.setPixelColor(displaymatrix[x][y], 0, 0, 0);
strip.show();
x = 0;
y = 0;
strip.begin();
strip.show(); // Initialize all pixels to 'off'
strip.setBrightness(10);
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.setPixelColor(displaymatrix[7][7], 0, 255, 0);
strip.show();
}
// finish effect
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
void loop() {
int isUp = (bitRead(maze[x][y], 1));
int isRight = (bitRead(maze[x][y], 2));
int isDown = (bitRead(maze[x][y], 3));
int isLeft = (bitRead(maze[x][y], 0));
if (digitalRead(up) == 0) {
if (isUp == 1){
strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
x++;
if ( x > 7) { x=7;}
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.show();
} else {
strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
strip.show();
if (mode == 2){
delay(1000);
reset2start();
}
}
}
if (digitalRead(down) == 0) {
if (isDown == 1){
strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
x--;
if ( x < 0) { x=0;}
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.show();
} else {
strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
strip.show();
if (mode == 2){
delay(1000);
reset2start();
}
}
}
if (digitalRead(left) == 0) {
if (isLeft == 1){
strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
y--;
if ( y < 0) { y=0;}
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.show();
} else {
strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
strip.show();
if (mode == 2){
delay(1000);
reset2start();
}
}
}
if (digitalRead(right) == 0) {
if (isRight == 1){
strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
y++;
if ( y > 7) { y=7;}
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.show();
} else {
strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
strip.show();
if (mode == 2){
delay(1000);
reset2start();
}
}
}
if (x ==7 && y == 7){
strip.begin();
strip.show(); // Initialize all pixels to 'off'
rainbow(20);
}
delay(200);
}
Some cheesy stuff I found on my fileserver. Mine/Friends or heared in the wild.
Hey kaas met ketchup? Of rasp ik nu te ver? (dutch) (cheese with ketchup? Or am I grating too far?)
Coline in chat: I’m planning to go to sleep, but i was mentally ordering things in my head My reply: cat /dev/head | sort -n > /dev/null && sleep $((8 * 2600))
Russisch routeren (dutch) (Russian Routing) (Network joke about misconfiguring a router – like roulette)
Dashboard of my room kamer (windowsill)
Howmuch is that in beers?
me: I’ve seen better code me also: But not written by me
Due to the recent coffee panic here, i think i need to prepare for the worst.. and go get a UPS for my backup coffee machine. (and bury cans of coffee in the garden)
Have you you seen the papers yet? Or are you waiting for the movie?
There are 1/12 problems according to the program No problem at leas not 1 out of 0 !
We have no fruit left, only a sick banana
Take it easy, take it easy. You can break things also slowly
Windows 95 – A world is closing for you.
Kapot gechmod (dutch and it rhymes) Break something using linux chmod command
I don’t have a smart TV, I need to be smart myself
A beautiful mind is about a misunderstood genius Happens to me also sometimes
Worldwide standard .. in Enschede
That dude was so drunk, he spoke encrypted
How long a drive was it? About 1 liter
Will you rewind the CD after using it please?
Better to have 10 beers in you, than 1 on the street
if microsoft is the answer you didn’t understand the question
The release date of windows 2000 will be delayed, the new releasedate will be 14-04-1901
That whisky bottle is square! Nice, no wet circles on the table
That trashcan bag is too big! Maybe it is supposed to be on the outside
Sparkling water = water with holes
Many orgasms in the water .. organism
Sollution for everything, apply some glue and some pressure
I have to go, I have to catch the bike in 5 minutes
I heared some fireworks, mid year. And said “maybe they are marsians”, we have to check if they lighting fireworks over 687 days again.
I just took a 12mm x 60mm piece of wood, and made a slit for the acrylic plastic using a circular saw, and removed a part for the back-plate using a wood router. I found a piece of acrylic in my shed, cut it to the right size using the circular saw. Slapped some paint on the wood.
I want to be able to use the sdk whenever i want, so i made a sliding window thingy. ( With wooden handle so the frame looks intact when closed. )
Then I 3D printed some holders, which I designed using Openscad.
Made a little design in blender. A friend needed a seat in his man-cave, the same one I fitted with the mobile phone charging station, and wled ledstrings.
It is for below some stairs. It’s a piece of wood (leftovers), some leather I still had lying around. Scaffolding tubes, foam, some decorative nails and stage-tape.
Being cinephiles.. we had to go .. and we didn´t regret it!
We went to Carré listening to Mr Tarantino talking about his book. Someone interviewed him about his life, and love for movies. He told many anecdotes and side stories. Sometimes with little clips from movies he talked about. We were very lucky to have seats on the 6th row!
The codes are entered using a keypad (Arduino) and send via MQTT
Node Red Dash board
Code
var code = global.get("mysetcode");
var good = 0;
var wrong = 0;
var wrongplace = 0;
var match = false;
var wrongchars = 0;
var wrongplaced = 0;
var goodchars = 0;
var payloadcode = msg.payload.toString();
var usr_input = Array.from(payloadcode);
var secret_code = Array.from(code);
var secret_code1 = secret_code;
if (msg.payload === code) {
match = true;
}
var result = "";
for (var i = 0; i < 4; i++) {
var found = false;
if (usr_input[i] === secret_code[i]) {
usr_input[i] = "a";
secret_code[i] = "b";
good = good + 1;
}
}
for (var i = 0; i < 4; i++) {
var found = false;
for (var j = 0; j < 4; j++) {
if (usr_input[i] === secret_code[j]) {
found = true;
}
}
if (!found) {
wrong = wrong + 1;
}
}
wrongchars = wrong - good;
wrongplaced = 4 - good - wrongchars;
msg.goodchars = good;
msg.wrongchars = wrongchars;
msg.wrongplace = wrongplaced;
msg.result = result;
msg.match = match;
return msg;
"If something is worth doing, it's worth overdoing."