ADC with LED output


Closed Thread
Results 1 to 10 of 10
  1. #1

    Question ADC with LED output

    hi

    I recently moved from my bs2 to pic's and I have a pic16f877A that I only recently got to work, and I've already gotten it to do most of basic stuff, blink and LED, run an LCD, run a servo, and so on... and today I started messing with the ad converter and just loaded one of the demo adc programs that came with pbp, to see what would happen and I got it to work, but It displays the digital value of portA.0 on the LCD and I was wondering would it be possible to display the value on portA.0 with LED's (say on portD) instead of the LCD so instead of seeing "Value : (and what ever number)" I would see 8 LED's displaying the binary value of portA.0.

    Thanks

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    trisd = 0 'set portd to all outputs
    adresult var byte 'set up a byte that will receive the a/d input from the ADC
    portd = adresult 'set portd to the result value

  3. #3
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Please disregard post.
    Last edited by T.Jackson; - 9th April 2008 at 17:48.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    C:>del t.jackson

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


    Did you find this post helpful? Yes | No

    Unhappy

    Hi, Trent

    It would be really very nice from you to stay upon PIC related subjects ...

    Hope you understand it told like here ...

    Thanks

    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
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Alain,

    You've heard the last of it. Cyas later.

  7. #7
    Join Date
    Apr 2003
    Location
    Cambridge - UK
    Posts
    1,033


    Did you find this post helpful? Yes | No

    Default

    T Jackson,

    Please moderate your responses...before i moderate them for you.

    I dont see your post being PIC related, or supportive of users on the forum.

    I have received a complaint about your post. Looking at the post in this thread i can see no good reason for it.

    Please take heed, i don't have a lot of time, so my descisions will be swift!

    Thank you for your attention.

  8. #8
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Sorry about this Lester.

    It might be more appropriate if the posts are completely removed. Once again -- sorry for concerning you with this. You've heard the last of it, you have my word.

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by inventor2008 View Post
    hi

    I recently moved from my bs2 to pic's and I have a pic16f877A that I only recently got to work, and I've already gotten it to do most of basic stuff, blink and LED, run an LCD, run a servo, and so on... and today I started messing with the ad converter and just loaded one of the demo adc programs that came with pbp, to see what would happen and I got it to work, but It displays the digital value of portA.0 on the LCD and I was wondering would it be possible to display the value on portA.0 with LED's (say on portD) instead of the LCD so instead of seeing "Value : (and what ever number)" I would see 8 LED's displaying the binary value of portA.0.

    Thanks
    Quote Originally Posted by Skimask
    trisd = 0 'set portd to all outputs
    adresult var byte 'set up a byte that will receive the a/d input from the ADC
    portd = adresult 'set portd to the result value
    Hi inventor2008,
    Skimask gave you nice tips. Since you're a beginner, i'll give you a working example of it.. just to compensate some "unwanted post" in your thread.

    Code:
    <font color="#000000">        <font color="#008000">'
            '   this assume you use a 20MHz crystal 
            '                    &amp;
            '              PM as assembler
            '
            </font>@    device hs_osc, lvp_off
            <font color="#000080">DEFINE </font>OSC 20
            
            TRISA = 255 <font color="#008000">' PORTA = INPUT
            </font>TRISD = 0   <font color="#008000">' PORTD = OUTPUT
            
            </font><font color="#000080">DEFINE </font>ADC_BITS  8     <font color="#008000">' ADCIN resolution  (Bits)
            </font><font color="#000080">DEFINE </font>ADC_CLOCK 3     <font color="#008000">' ADC clock source  (Frc)
            </font><font color="#000080">DEFINE </font>ADC_SAMPLEUS 50 <font color="#008000">' ADC sampling time (uSec)
            
            </font>ADResult    <font color="#000080">VAR BYTE
            
            </font>PORTD=0 <font color="#008000">' Clear all LEDs on PORTD
            
    </font>Start:
            <font color="#000080">ADCIN </font>0,ADResult
            PORTD = ADResult
            <font color="#000080">GOTO </font>Start
    HTH
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10


    Did you find this post helpful? Yes | No

    Default

    Hi, thanks for answering

    I forgot to to set portD as out, and there was a short in my potentiometer. I defined portD as out and got this...


    trisd =0
    ' Define ADCIN parameters
    Define ADC_BITS 8
    Define ADC_CLOCK 3
    Define ADC_SAMPLEUS 50

    adval var byte

    TRISA = %11111111
    ADCON1 = %00000010

    Pause 500

    loop: ADCIN 0, adval
    portd = adval


    Goto loop
    End




    then I got a different pot and It seems to work now.

    Thanks!!!
    Last edited by inventor2008; - 9th April 2008 at 18:55. Reason: don't need that just forgot to delete it

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 04:59
  3. Scale 8bit ADC RGB LED voltmeter
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd February 2008, 03:37
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46

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