Stable ADC readings


Closed Thread
Results 1 to 40 of 91

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    I Bet there are no pull ups on port A inputs.

    Ioannis

  2. #2
    Join Date
    Aug 2011
    Location
    Guadalajara, México
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    mazoul72, I'm really new to picbasic, but I note in your schematic that you don't have pull-up resistor, so please try something like this:


    Also, try to code something like the below example, if you rotate the bits of your ADC reading, you can leave only the 2 most significating bits, this way, you can know the exact button pressed (of course you must calculate correctly the resistors values):

    DEFINE ADC_BITS 8
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50

    ADVal var byte
    Switch var byte

    Principal:
    adcin 3,adval
    switch = (adval >> 6) 'Shift for 2 MSB for values 0 to 3 representing each button

    SELECT CASE switch
    CASE 0
    'Put your code here
    gpio=0
    CASE 1
    'Put your code here
    high gpio.0
    CASE 2
    'Put your code here
    high gpio.1
    CASE 3
    'Put your code here
    high gpio.2
    END SELECT

    goto principal
    end

Members who have read this thread : 2

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