Update controller to use internal pullup

This commit is contained in:
Leni Aniva 2025-06-16 10:16:32 -07:00
parent db4232f94d
commit 4c0a54dc4a
Signed by: aniva
GPG Key ID: D5F96287843E8DFB
2 changed files with 9 additions and 3 deletions

View File

@ -0,0 +1,3 @@
# Yasaka Kanako
This cosplay won a Judge's favourite award at TouhouFest 2025.

View File

@ -1,7 +1,8 @@
#define USE_MOTOR 1 #define USE_MOTOR 1
#define USE_LED 1 #define USE_LED 1
#define USE_DISPLAY 1 #define USE_DISPLAY 0
// The mode switch button should be wired to the ground with an internal pullup resistor.
#define pinButtonMode 9 #define pinButtonMode 9
#define pinDiag 6 #define pinDiag 6
@ -52,7 +53,7 @@ bool flag_lighting = false;
void setup() { void setup() {
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
pinMode(pinButtonMode, INPUT); pinMode(pinButtonMode, INPUT_PULLUP);
#if USE_LED #if USE_LED
// Calculate colours // Calculate colours
hsv2rgb_spectrum(CHSV(4, 255, 100), color_red); hsv2rgb_spectrum(CHSV(4, 255, 100), color_red);
@ -71,6 +72,8 @@ void setup() {
fill_solid(leds, NUM_LEDS, CRGB::White); fill_solid(leds, NUM_LEDS, CRGB::White);
delay(500); delay(500);
FastLED.show(); FastLED.show();
fill_solid(leds, NUM_LEDS, CRGB::Black);
delay(500);
#endif #endif
#if USE_DISPLAY #if USE_DISPLAY
Serial.begin(9600); Serial.begin(9600);
@ -87,7 +90,7 @@ void setup() {
void loop() { void loop() {
// Detect a rising edge // Detect a rising edge
int buttonState = digitalRead(pinButtonMode); int buttonState = !digitalRead(pinButtonMode);
if (buttonState && !stateButtonMode) { if (buttonState && !stateButtonMode) {
programId = (programId + 1) % MAX_PROGRAMS; programId = (programId + 1) % MAX_PROGRAMS;
programChanged = true; programChanged = true;