Greenhouse controller written in AVR assembly for the ATmega128L on an STK-300 board: temperature sensing, servo-driven ventilation, an infrared remote, and persistent history.
A DS18B20 reads the temperature. If it goes above the set point, a servo opens a window; once it drops back, the servo closes it. You drive the whole thing with a Vivanco UR Z2 IR remote (RC5 protocol), and a 2x16 LCD shows the state. The min and max temperatures seen so far are stored in EEPROM, so they survive a power cycle.
Four modes, all toggled from the remote:
- NORMAL: regulation runs.
- SET: change the set point with CH+ / CH-.
- SLEEP: regulation paused, window closed, screen blanked.
- HISTORY: shows the min/max from EEPROM.
The servo PWM is generated by the main loop: pin low for ~18 ms, then we do the work (handle the remote, read the sensor if Timer0 said so, refresh the LCD), then pin high for 1.52 ms (closed) or 1.90 ms (open). Temperature reads are deferred out of the Timer0 ISR so the pulse width stays clean and the IR decoder doesn't drop bits.
The design keeps interrupt handlers short and performs slower sensor work in the main loop. The four-mode state machine separates regulation, configuration, sleep, and history; EEPROM preserves the temperature extrema when power is removed.
main.asm vector table, reset, state machine, main loop
thermo.asm DS18B20 read + threshold compare + window decision
servo.asm open_window / close_window
display.asm LCD line 1 redraw + splash
eeprom.asm min/max history in internal EEPROM
ir_rc5.asm RC5 decoder ISR on INT7
wire1.asm 1-Wire library
lcd.asm LCD primitives
printf.asm PRINTF macro
macros.asm general macros
definitions.asm register aliases, board pin map
Open Projet_Microcontrolleurs/Projet_Microcontrolleurs.asmproj in Microchip Studio, build, and flash an STK-300 with an ATmega128L at 4 MHz.
