Menu

AD conversion

Help
2007-02-08
2013-05-30
  • Sterling Youngman

    I'm trying to use ReadAD(AN0), but I get an error when compiling, any thoughts?

    #chip 16F648A, 20

    #config _CP_OFF & _DATA_CP_OFF & _BODEN_OFF & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC

    dir PORTA.0 IN

    #define LCD_IO 4
    #define LCD_DB4 PORTB.0
    #define LCD_DB5 PORTB.1
    #define LCD_DB6 PORTB.2
    #define LCD_DB7 PORTB.3
    #define LCD_RS PORTB.5
    #define LCD_RW PORTB.6
    #define LCD_Enable PORTB.7

    Main:

    wait 1 sec
    Print "HELLO WORLD??"

    Locate 1,0

    potSensor = ReadAD(AN0)

    LCDInt (potSensor)

    wait 50 10ms
    next add

    cls

    Goto Main

     
    • Hugh Considine

      Hugh Considine - 2007-02-08

      The 16F648A does not have a hardware A/D converter, so ReadAD will not work. However, with a couple of extra components you can use the POT command to read a variable resistance - see http://gcbasic.sourceforge.net/help/pot.htm

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.