multiple switches~one ADC


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    42

    Default multiple switches~one ADC

    Planning to connect multiple switches into single port.one ADC pin to detect voltage level when each switch for each state is pressed and each switch is associated with a voltage.connecting 8 switches with 1 adc.. Looking for some coding tips.. Thanx.
    Attached Images Attached Images  

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    That should work. After you read the ADC have a gosub with some if/thens or case statements to do ??? at a certain ADC reading. Then go back and read the ADC again.

    You may want the code to loop around reading the ADC and have the value with out a switch being pressed do nothing.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    Hi, Dave

    This also works very well with POT command ( no ADC required ) ... a well known STAMP Application.

    EPE had also published an original design around a 555 ... key pressing generates a Pulse depending on the key pressed ...
    Interrupt use to detect keystroke ... nice !

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Never cared much for the POT command. Seems not as stable. But that is me.

    I am going to look at your other option. Sounds interesting.
    Thanks!
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by mackrackit View Post
    Never cared much for the POT command. Seems not as stable. But that is me.

    !
    Hi, Dave

    I generally do not use POT ... but for 10-12 keys or less result is reliable with a reasonnable range of values for each key.

    soooo, I do it simple ( for once !!! )

    I'll try dig out the EPE Keybd ... it's somewhere in my HDD !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Sep 2006
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    Hi All, tried this code, its working but is there any other reliable way....

    adval var byte ' Create adval to store result

    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00000010 ' Set PORTA analog
    Pause 500 ' Wait .5 second
    loop: ADCIN 0, adval ' Read channel 0 to adval
    Lcdout $fe, 1 ' Clear LCD
    Lcdout "Value: ", DEC adval ' Display the decimal value
    Select case adval
    CASE is <51
    high porte.0
    cASE 102
    high porte.1
    CASE 153
    high portd.2
    CASE 204
    high portd.3
    CASE is >225
    low porte.0 : low porte.1 : low portd.2 : low portd.3
    Pause 150
    END SELECT
    pause 100
    Goto loop
    End
    * this below line is not accepting :ERROR
    case >1 to <53
    'do some thing
    case >53 to < 102
    'do some thing..
    So On.....

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. multiple ADC using DSpic 30f3010
    By angeline in forum mel PIC BASIC
    Replies: 6
    Last Post: - 22nd February 2008, 10:03
  3. 18F1320 ADC multiple channel select
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th November 2005, 21:40
  4. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46
  5. Reading multiple ADC channels FAST
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st April 2004, 22:37

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts