I am working on a project in MBASIC. Anyone use that in this forum? I am not up to speed on any other language, so please respond with help on the MBASIC program for PIC16F Series. Below is what the program should do: ----------------------------------------- When the FSR is held down the MP3 Player should Play When the FSR is not being touched the MP3 Player should be Paused. ----------------------------------------- Seems simple enough, right? I have good readings from the FSR 0-1023. Consider any number < 100 as = touching the FSR. I think of it like mouseOver or mouseOut in Flash, but instead its an FSR being touched not an icon in Flash. I am using a simple digital relay and sending +5 when I want the pins to the MP3 player to connect. When the relay gets +5, then pauses, then goes back to ground it opens and shuts the relay connected to the MP3 pins. (very easy) So far I've only been able to make the FSR act like a button: release it and toggles PLAY, then the next release it toggles to PAUSE. Back and forth it goes toggling between the two options upon every release. But how do to continuous play? By continuous play I mean, if it is playing AND it is being touched then continue playing (no toggle). Below is what I have done so far, BUT remember it doesn't work right it works like a toggle button. Am I missing some specific code or variable? Help me see how to approach this idea in MBasic. Thanks, ACL ''''''''''''''''''''' THE CODE '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' CPU = 16F876A MHZ = 10 CONFIG 16250 temp var word ;temp is a word sized variable MP3Play var byte ;MP3Play variable for on/off clear ;clears out variables... to start fresh AN0 con 0 ;Set the analog input CLK con 2 ;Set clock ''initialize the program ADSETUP con %10000000 ;sets up the ADCON1 register; ANO/RAO is now analog MP3Play = 0 ;says MP3 player is on PAUSE '''''''''''MAIN ROUTINE'''''''''''''''''''''''''''''''''''' MAIN gosub getADC if MP3PLAY=0 AND temp > 100 then ;If it is Paused and no ADC activity gosub stay ;then go back to the beginning elseif MP3PLAY=0 AND temp < 101 ;If it is Paused and ADC is lower than 101 gosub relayPlay ;goto subroutine "play" which sets MP3Play variable to 1 elseif MP3PLAY=1 AND temp > 100 ;If it is Playing and no ADC activity gosub relayPause ; then goto subroutine "pause" which pauses the player (MP3Play = 0) elseif MP3PLAY=1 AND temp < 101 ;If it is Playing and ADC is less than 101 (which means continuously touched) gosub stay ;then go back to the beginning endif goto MAIN getADC: ADIN AN0,CLK,ADSETUP,temp ;loads the variable temp with the sample temp = ABS (temp - 1023) pause 10 RETURN relayPlay: MP3Play = 1 ;Play high c2 pause 20 low c2 pause 10 RETURN relayPause: MP3Play = 0 ;Paused high c2 pause 120 low c2 pause 10 RETURN stay: ;nothing should happen...it should stay wherever it is and only change to off or on when the variable changes RETURN ------------------------------------------------------------- Discover Yahoo! Have fun online with music videos, cool games, IM and more. Check it out! http://discover.yahoo.com/online.html -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist