Add the 74HC595 Snake game project

This commit is contained in:
2026-06-12 12:40:08 -04:00
parent 200156c432
commit f0561b449a
26 changed files with 1009 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#ifndef _JOYSTICK_H_
#define _JOYSTICK_H_
#include <Arduino.h>
#include <stdint.h>
#define PIN_BUTTON_LEFT 1 // Red
#define PIN_BUTTON_UP 2 // Green
#define PIN_BUTTON_DOWN 47 // Yellow
#define PIN_BUTTON_RIGHT 13 // Blue
#define PIN_DIFFICULTY 10
#define BUTTON_STABLETIME 100
// Button states
#define BUTTON_STATE_BOUNCING (1 << 0)
#define BUTTON_STATE_DOWN (1 << 1)
#define BUTTON_STATE_UP (1 << 2)
#define BUTTON_STATE_HELD (1 << 3)
typedef struct Button {
// What pin is this button on
uint8_t pin;
// What is the state of this button (bitmask of BUTTON_STATE_*)
uint8_t state;
// Is this button pressed when it is LOW or HIGH?
uint32_t pressedvalue;
// How long do we wait when debouncing this button
uint32_t debouncetime;
// When did we start debouncing
uint32_t debounce_start_time;
} Button;
int initButton(Button *button);
int readButton(Button *button);
uint32_t readDifficulty();
#endif // _JOYSTICK_H_