MikroElektronika PIC Microcontrollers PIC16 Datový list Strana 171

  • 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 170
Programming PIC Microcontrollers in BASIC - mikroElektronika
Using the previous scheme, we could display a sequence of nine digits like this:
program seven_seg_onedigit
dim i as byte
' Function mask returns mask of parameter 'num'
' for common cathode 7-seg. display
sub function mask(dim num as byte) as byte
select case num
case 0 result = $3F
case 1 result = $06
case 2 result = $5B
case 3 result = $4F
case 4 result = $66
case 5 result = $6D
case 6 result = $7D
case 7 result = $07
case 8 result = $7F
case 9 result = $6F
end select
end sub
main:
INTCON = 0 ' Disable PEIE, INTE, RBIE, T0IE
TRISA = 0
TRISB = 0
PORTB = 0
PORTA = 2
do
for i = 0 to 9
PORTB = mask(i)
Delay_ms(1000)
next i
loop until false ' Endless loop
end.
Purpose of the program is to display numbers 0 to 9 on the ones digit, with 1 second delay. In order to display a number,
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/07.htm (5 sur 16)05/11/2004 02:27:45
Zobrazit stránku 170
1 2 ... 166 167 168 169 170 171 172 173 174 175 176 ... 193 194

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

Žádné komentáře