Hello, i'm having some difficulty with giving my program a certain functionality that has to be a kind of safety feature in my application.
what i want to make is a stepper motor driving a variac via a timing belt, so that i can use it as an AC variable voltage supply.
my code reades a 3 state switch, which puts the arduino in 3 different states, that for now only turn on an SSR connected to the variac.
The part im having trouble with is the following, when starting up, i want the state to be in 0 where everything is off, even when the physical switch is in 1 or 11(2), only when the switch has been in state 0 the state command should switch and do what the user want to do, this is to prevent that things start homing and doing things when the power has been cut off of the arduino.
if something is unclear please ask because i dont know very certain if i am making it clear what i want.
i want the state of the code to be in 0 when the code starts, the state of the physical switch is uncertain, only when the switch has been in state 0 at least once, i want the code to be able to switch to other states
Does the "safety" involve mitigating risks to human beings or animals? If so you should not depend on software controlled protection. You need hard wired switches that will cut the power, or perform some action that will immediately and unequivocally shut the entire system down.
well maybe if someone is putting his fingers between the timing belt an injury could be made, but this module will be build into an enclosure so it will be fine, its not so critical.
yes it is, but if the switch is put into state 2, it goes into the switch state 2, which it should only do when it has been at least once in physical state 0.
this is so that when the power goes off the arduino, it doesnt go into state 2 or 1 and initiate the stepper motor or SSR switching the variac