We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I want to get the count whenever a pin gets high and store it in a variable and then use every count of the variable in if loop for my process.
What would be the syntax and how can i add a counter if i am using just a pin suppose P0.15 of LPC2148.
can anyone help me with a small guiding syntax to how to incorporate a counting variable for a pin to count no of time the pin gets high and if the pin gets high after a particular value suppose 4 i want to reset the count.
Jai_Vyas said:I want to get the count
"The" count ---- of what?
"The " Count whenever a pin gets high .. I want a variable to count the number of times a Pin gets High and i want to use that count for further loops.
Configure EINT2 to use pin P0.15 as its interrupt source. Configure the logic on EINT2 properly (probably edge / High, but possibly level / High)
Write an interrupt handler for the EINT2 interrupt. Increment a count variable in the interrupt handler.
Enable the EINT2 interrupt.
Be careful, buttons tend to bounce so you may get "many" interrupts when you really think you should only get 1. You may need to debounce the pin some how.