Auto_Seat
Arduino Nano based automatic seat controller.
Hardware
- Board: Arduino Nano ATmega328P
- Up relay: D8, active-low
- Down relay: D9, active-low
- Parking raw input: A0
- IG1 input: D7
Main Behavior
- If
IG1 HIGHand parking signal is OFF, drive mode is confirmed after 80ms. - In confirmed drive mode, the seat moves up to the EEPROM saved position.
- If parking/non-drive mode is confirmed for 250ms, the seat moves down to 0.
- Down movement is estimated at 1.1x the up movement speed.
- When the estimated position reaches 0, down relay stays on for an extra 300ms.
- On IG1 startup, relay output is held off for 1000ms to ignore temporary signal bounce.
Position Setting
- Hard limit:
0..6000ms - EEPROM saved position is used as the automatic driving position.
- EEPROM initializes saved position to
6000msif the magic value is missing or invalid. - Serial command
psaves the current estimated position to EEPROM. - Calibration command
cdoes not change the saved position.
USB / Serial Reset Handling
Opening a USB serial connection can reset an Arduino Nano through DTR.
If the board boots while IG1 HIGH and parking is OFF, the controller assumes the seat is already at the saved driving position:
currentMs = savedPositionMs
targetMs = savedPositionMs
relay = OFF
This prevents unintended upward movement after USB reconnect while the gear is not in P. If the gear is then moved to P, the controller moves down from the saved position estimate to 0.
Serial Console
Serial is quiet by default.
- Open serial at
115200. - Send an empty Enter once to unlock the console and print help.
- After unlock, only one-character commands are accepted.
Commands:
s print current status
u manual up +500ms
d manual down -500ms
p save current estimated position to EEPROM
g start debug output every 1s
x stop debug mode only
a return to gear-based automatic target
c run calibration: up 7s, down 6s, set current position to 0
r clear 10-use auto calibration counter
h print help
These management commands require parking gear for safety:
a c r
If the gear is not P:
ERR: check gear state. Command requires P.
While debug mode is active, only x is accepted. Other input is ignored.
Manual position commands u, d, and p are allowed while driving, as long as the controller is not busy with an in-progress movement.
Every status output includes boot uptime:
uptime=0h 2m 13s 457ms
Automatic Calibration
- Each
IG1 HIGH -> LOWtransition increments the EEPROM use counter. - After 10 uses, calibration is scheduled.
- If IG1 remains OFF for 5 minutes, automatic calibration runs:
up 7000ms
down 6000ms
currentMs = 0
targetMs = 0
useCount = 0
If IG1 turns ON during scheduled calibration, calibration is aborted. Manual c calibration is allowed only in P and runs to completion.
Safety Guards
- Commands are rejected while the seat is moving or a relay action is pending.
- Internal position values are clamped to
0..6000ms. - Manual step completion is cancelled if gear state changes before completion.
- Factory reset command was removed to avoid accidental EEPROM reset.
Build / Upload
Compile:
& "C:\Program Files\Arduino CLI\arduino-cli.exe" compile --fqbn arduino:avr:nano:cpu=atmega328 --warnings all .
Upload:
.\upload.ps1 -Port COM3
Notes
The controller estimates seat position by time. There is no physical position sensor. If power is cut while IG1 is OFF/P state, the next boot starts from estimated position 0. If the board resets while already in drive mode, it starts from the EEPROM saved driving position to avoid USB reconnect induced upward movement.