Raspberry Pi practice problem · Projects
Washing machine
A small washing machine: the drum is a DC motor on an L298N (IN1 GPIO5, IN2 GPIO6, ENA GPIO12), a 16×2 LCD (I²C 0x27) shows the phase, a start button is on GPIO26 and a slide switch is the door sensor: COM to GPIO27, pin 1 to ground, pin 2 to 3.3 V (lever right = door open = GPIO27 high).
Feed the driver's +12V and +5V terminals from the Pi's 5 V and join the grounds. On 5 V the bridge leaves the motor about 3 V: roughly 100 rpm at full speed, proportional to the PWM duty.
Line 1 of the LCD shows READY until start is pressed with the door closed (start is ignored while the door is open). Then the cycle runs:
| Phase | Length | Drum | LCD |
|---|---|---|---|
| Wash | 4 s | 50 % speed, alternating direction every second (forwards first) | WASH |
| Rinse | 2 s | forwards, 50 % | RINSE |
| Spin | 3 s | forwards, full speed | SPIN |
Afterwards the drum stops and the LCD shows DONE.
If the door opens during the cycle, stop the drum at once and show DOOR OPEN. The phase clock pauses; when the door closes, the cycle carries on where it stopped.
The test presses start at 1 s, opens the door at 2.5 s and closes it at 4 s, so the cycle finishes at about 11.5 s.