MikroElektronika PIC Microcontrollers PIC16 Datový list Strana 158

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 194
  • Tabulka s obsahem
  • ŘEŠENÍ PROBLÉMŮ
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 157
Programming PIC Microcontrollers in BASIC - mikroElektronika
Potentiometer gives 0V in one terminal position and 5V in the other – since we use 8-bit conversion, our digitalized
voltage can have 256 steps. The following program reads voltage on RA0 pin and displays it on port B diodes. If not one
diode is on, result is zero and if all of diodes are on, result is 255.
program ADC_8
main:
TRISA = %111111 ' Port A is input
PORTD = 0
TRISD = %00000000
ADCON1 = %1000010 ' Port A is in analog mode,
' 0 and 5V are referent voltage values,
' and the result is aligned right
' (higher 6 bits of ADRESH are zero).
ADCON0 = %11010001 ' ADC clock is generated by internal RC
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/06.htm (4 sur 12)05/11/2004 02:26:24
Zobrazit stránku 157
1 2 ... 153 154 155 156 157 158 159 160 161 162 163 ... 193 194

Komentáře k této Příručce

Žádné komentáře