Today I got something very cool to work: you press a button and
a motor turns on.
The button was read by an electrically isolated RS485 two-wire interface between an ARM7 system on a chip and an 8 bit PIC. The PIC monitors the switch for gunk, and if gunked (saline or blood) indicates an error. It also expects to be queried by the host ARM periodically, if not, it errors. Using a built-in ADC. There are also watchdog timers on the PIC itself. And it checks its own checksum at boot. Also checks for stuck switches and multiple switches.
The PIC detects a switch closure by thresholding an analog input channel. If a good closure is found, it tells the ARM when queried. The ARM then closes an opto isolated relay to supply power to the tool. Only yesterday was the relay correctly mapped via a CPLD glue chip. It was inverted; upon powering up, the tool turned on. I had the EE in charge of the CPLD flip this, for safety. (The ARM could shut it off at boot, but if the ARM was bad, its hazardous to have the tool turn on.)
So at the end of the day, the switch turned the tool on. Safely.
This is why medical devices cost more than consumer devices, and why folks infrequently die from med devices. At least in the US.
The FDA is poised to own nicotine. Some wanker on the news said tobacco is neither safe nor effective. What crap. Its obviously effective.
In fact, I've read an article in a psychiatric trade magazine that said that permitting psych patients to smoke is OK, since its theraputic and they're not likely to pick it up while in the hospital.
Look up nicotinic receptors. You have muscarinic (central nervous system) receptors too, but tobacco doesn't hit them.
Anyway, getting a motor to turn on when a switch is pressed via all this isolation, software, and comm bus stuff is pretty rewarding, even if a trivial implementation is, well, trivial. Doing it safely is not.