Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Can you help me with pseudo-codeOne way is to use a byte as a counter.
In the interrupt routine:
If the switch is pressed, count up if the counter is less than a certain value.
If the switch is released, count down if it's above zero.
When the counter reaches the maximum value, consider the switch pressed. When it reaches zero, consider it released (setting or clearing a bit).
void main (void)
{
while (1)
{
}
}
// interrupt for 1 ms
void interrupt(void)
{
if(FlagSet)
{
if (switch === 1) //If the switch is pressed, count up
count++;
if (switch === 0) //If the switch is released, count down
count--;
ReloadTimer;
ClearTFlag
}
}
Can you help me with pseudo-code
void main (void) {
while (1) { }
}
// interrupt for 1 ms
void interrupt(void) {
if(FlagSet) {
if ( switch == 1 && count < 10 ) //If the switch is pressed, count up
count++;
else if ( switch == 0 && count > 0 ) //If the switch is released, count down
count--;
if ( count == 10 ) {
switchstate = true;
if (switchimage == false) {
state++;
}
else if (count == 0 )
switchstate = false;
switchimage = switchstate;
output = state & 0x01;
ReloadTimer;
ClearTFlag
}
}