Go Down

Topic: make an output latch? (Read 1 time) previous topic - next topic


hi just gone through the examples for my first program id like to learn how to latch an output ie push button o/p stays on push button output off could someone point me in the right direction please


Outputs are latched. You have to explicitly set the pin to HIGH or LOW. It does not automatically revert after some period.
The art of getting good answers lies in asking good questions.


I think the term you are looking for is that you want the outputs to TOGGLE.

It is rather easy to do -

declare a variable -
int toggleVar = 0;

inside of loop(){
   int ButtonVal;
   buttonVal = digitalRead(ButtonPin)
   if (buttonVal = HIGH ) toggleVar= !toggleVar;
   if (toggleVar) {

I don't guarrantee my code will run as written, but it is an outline...


Go Up