In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Zoot wrote: You can also code in SX/B if you like a BASIC like syntax. Examining the assembly that is "created" by the SX/B compiler might help you see how some of this stuff works. This will probably do something like what you want, but I didn't count the cycles in the "wait" routine so I don't know how long it is. [code] device sx28l,oschs3 device turbo,stackx,optionx IRC_CAL IRC_SLOW reset start_point freq 50000000 ; 50 MHz org 8 second ds 2 ; counter for 1 second tone delay ds 1 delay1 ds 1 org 0 start_point mov !rb,#$7F ; make led output call flashled ; wait for input button bwait jnb rb.0,bwait call flashled jmp bwait ; subroutine flashled mov second,#$d0 ; 2000 is $7D0 mov second+1,#$07 setb RB.7 loop mov delay1,#24 oloop clr delay wloop djnz delay,wloop djnz delay1,oloop ; repeat 2000 times djnz second,loop djnz second+1,loop clrb RB.7 ret ; go back to wherever [/code] Remember that moving values to !RB or !RA or !AnyPort determines whether the pin(s) are INPUTS or OUTPUTS, not whether they are "high" or "low". In the above edit, the LED is set as an output, the bwait routine waits for the button to go high. When it does, it calls the flashled routine which sets the led output pin to 1 (high), counts down some loops to "delay" the light flash, then turns the LED off again. If your button is wired as active high to RB.0 and the anode (+ lead) of your LED is wired to RB.7, this should work. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=429713#m430470 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)