Hey everyone, looking for a little help. Im getting confused on how to write a little program for myself. Basically I want to make a chip, probably the attiney85, to be used instead of my arduino to control an motor. What Im exactly doing is I want the chip to look for a certain voltage that can be adjusted through a variable resistor (that’s always monitored), and compared against another voltage. When the value that is set by the variable resistor is exceeded by the voltage its compared to, a motor will run for a time that is stored, and can be changed, in the eeprom. Example, set the voltage to 3.0v using the resistor, when more than 3.0v is seen on another input, run a motor for x amount of time. The time can be reset to another value through the eeprom. It sounds like a lot but if someone can atleast get me on the right track with the first part, allowing the motor to run, it would be greatly appreciated. Thanks.
You have to define your requirements a little bit more. What if the voltage is above the threshold for X amount of seconds after you turn on the motor? What if that X amount of seconds are greater than the interval you set? What if your threshold value changes during the motor on cycle, does the interval get updated immediately? Otherwise, the rest of it, code wise) is pretty trivial...
Read sensor values
Set interval based on first sensor
if second sensor value is greater than threshold
turn on motor
set the time the motor was turned on to now
if it's been a certain interval time since the motor was turned on
turn it off.