Mentally-ill engineering can also be used for evil. In Canada shortly after World War II, there was a paranoid fear that homosexual people would infiltrate the government and do whatever things that right-wing homophobes think that gay people are plotting to do. As an attempt to counter this, a machine was invented for the supposed purpose of identifying gays, which was about as effective as modern polygraph or the Vietnamese war's famous "Magic Eye." That is, it worked because people thought it did and then their own paranoia gave them away. They called it the "Fruit Machine," "Fruit" being one of many slang terms for a gay person.
The device resembled a dentist's chair, and had a screen and a camera. The screen showed pictures. Some were neutral pictures of scenery, math, or some other thing that held no interest. Some were pictures of naked women. Some were pictures of naked men. A crank theory popular at the time claimed that a person's eye dilated when exposed to things of interest to the person, so if a man's eyes dilated for the naked men pictures and not the naked women pictures.....WHOOP WHOOP GAY DETECTED!!!! Same if a woman responded more to the naked women pictures.
Except that this whole thing was fatally flawed. Pupils dilate more in response to changes in light than to perception of objects of interest. So if the lightbulb on the ceiling happened to flicker while the thing showed you pictures of your gender, it falsely flagged you as gay. And many gays went undetected. The camera had to be off to the side to prevent it from interfering with the screen, which made it often report dilation when actually there was merely a reflection in the pupil. It also produced unpredictable results if the subject had larger-than-average pupils, because it measured dilation by the diameter of the pupil and didn't calibrate first.
The devices were all dismantled in the 1970s after withering criticism from all angles. The device was demonstrably faulty, not only from the engineering standpoint, but also technically and even ontologically as homosexuality was ruled by a number of psychological institutes as not being a mental illness, but a normal human variation. Small comfort to those who lost their jobs and were forever scorned because of the errors of a machine, but at least the abuse stopped there.