Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20562

BASCOM-AVR : (ask)how to output a 4bit each in 1 port : NEWTOPIC

$
0
0
please d corrections wherever the location was wrong :?: :?: :?: [code:1:3668f95a8b]$regfile = "m8def.dat" $crystal = 8000000 $hwstack = 40 $swstack = 16 $framesize = 32 Config Lcdpin = Pin , Rs = Portd.2 , E = Portd.3 , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 Config Lcd = 16 * 2 '----------------- Cursor Off Noblink 'Konfig Tombol Config Portb = Output Config Pind.0 = Input Config Pind.1 = Input Tombol_up Alias Pind.0 Tombol_dwn Alias Pind.1 'A Alias Angka '------------------------------------------------------------------------------- 'Deklarasi variabel, dan nilai awal Dim Angka As Byte Angka = 0 Cursor Off Noblink 'Cls '------------------------------------------------------------------------------- 'looping utama Do 'debonce dan deteksi tombol ditekan Debounce Tombol_up , 0 , Count_up , Sub Debounce Tombol_dwn , 0 , Count_dwn , Sub Loop '------------------------------------------------------------------------------- 'sub rutin conter up Count_up: If Angka > 8 Then Angka = 0 Angka = Angka + 1 'pangil sub rutin tampilkan LCD Gosub Led Return '------------------------------------------------------------------------------- 'sub rutin conter down Count_dwn: If Angka < 0 Then Angka = 8 Angka = Angka - 1 'pangil sub rutin tampilkan LCD Gosub Led Return '------------------------------------------------------------------------------- 'output port Led: Dim S As String * 10 Dim Schar As String * 10 Dim D3 As Byte Dim D2 As Byte Dim D1 As Byte Dim D0 As Byte Schar = Str(angka) Schar = Format(schar , "0000") S = Mid(schar , 1 , 1) D3 = Val(s) S = Mid(schar , 2 , 1) D2 = Val(s) S = Mid(schar , 3 , 1) D1 = Val(s) S = Mid(schar , 4 , 1) D0 = Val(s) Return Portb.0 = D3.0 Portb.1 = D3.0 Portb.2 = D2.0 Portb.3 = D2.0 Portb.4 = D2.0 Portb.5 = D2.0 Portb.6 = D1.0 Portb.7 = D1.0 Portc.0 = D1.0 Portc.1 = D1.0 Portc.2 = D0.0 Portc.3 = D0.0 Portc.4 = D0.0 Portc.5 = D0.0[/code:1:3668f95a8b] [b:3668f95a8b][color=red:3668f95a8b](BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.6 )[/b:3668f95a8b][/color:3668f95a8b]

Viewing all articles
Browse latest Browse all 20562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>