esp attempt, stock + unit type

This commit is contained in:
shironeko
2026-03-07 19:21:14 -03:00
parent 788b67804e
commit 2f2998b0fd
9 changed files with 283 additions and 53 deletions

39
SekiScaleESP/src/main.cpp Normal file
View File

@@ -0,0 +1,39 @@
#include <Arduino.h>
const int triggerPin = D2;
bool lastState = HIGH;
void setup() {
Serial.begin(115200);
randomSeed(analogRead(0));
pinMode(LED_BUILTIN, OUTPUT);
pinMode(triggerPin, INPUT_PULLUP);
// Flash LED to signal boot
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
bool currentState = digitalRead(triggerPin);
// Detect when D4 touches GND (Falling Edge)
if (currentState == LOW && lastState == HIGH) {
int randomWeight = random(100, 5000);
// Output formatted for easy parsing
Serial.print("WEIGHT:");
Serial.println(randomWeight);
// Visual feedback
digitalWrite(LED_BUILTIN, LOW);
delay(100);
digitalWrite(LED_BUILTIN, HIGH);
delay(250); // Debounce
}
lastState = currentState;
}