In SX Microcontrollers, SX/B Compiler and SX-Key Tool, roondog wrote: I do not need to debounce the pushbutton. I found a sample program in the [u]Exploring the SX[/u] pdf that uses a pushbutton with a piezoelectric speaker instead of an LED. The document says that the button is wired to read a 0 when the button is pressed but I would like it to read a 1 when pressed. The segment of code that controls this is: [b]jb rb.0, bwait, [/b]so jump to the "bwait" subroutine if register b is set. I changed the jb command to [b]jnb[/b] but the button still reads 0 when pressed. Is there an easy way to fix this? The program is as follows: [1]device sx28l,oschs3[/1] [1]device turbo,stackx,optionx IRC_CAL IRC_SLOW reset start_point freq 50000000 ; 50 MHz org 8 [/1][1] second ds 2 ; counter for 1 second tone delay ds 1 delay1 ds 1 org 0 start_point mov !rb,#$7F ; make speaker output call beep ; wait for input button bwait jb rb.0,bwait call beep jmp bwait ; subroutine beep mov second,#$d0 ; 2000 is $7D0 mov second+1,#$07 loop not rb ; toggle bits mov delay1,#24 oloop clr delay wloop djnz delay,wloop djnz delay1,oloop ; repeat 2000 times djnz second,loop djnz second+1,loop ret ; go back to wherever [/1] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=429713#m430400 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2010 (http://www.dotNetBB.com)