Sunday, May 12, 2013

sintaks ATmega16

sintaks yang di gunakan untuk membuat program motor DC dan menampilkan hasilnya ke seven segmen dan kecepatannya di tentukan dengan mengukur menggunakan potensio meter.

$regfile = "m16def.dat"
$crystal = 1000000
Segmen Alias Portd
Tampilan Alias Portb
Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.4 , Rs = Portc.5
Config Lcd = 16 * 2
Config Timer1 = Pwm , Pwm = 8 , Prescale = 64 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down
Config Adc = Single , Prescaler = Auto , Reference = Aref
Config Portd = Output
Start Adc
Dim A As Word , B As Word , Temp As Word , Temp1 As Word , D As Byte , E As Word , C As Byte , S As Word
Do
A = Getadc(0)
Temp = 512
Lowerline
Lcd A
Waitms 50
If A < Temp Then
S = 512 - A
Set Portd.6
End If
If A >= Temp Then
S = A - 512
Reset Portd.6
End If
Pwm1a = S
E = S
B = E
B = B / 1000
Waitms 100
D = Lookup(b , Segmen)
Segmen = 8
Tampilan = D
B = E
B = B Mod 1000
C = B
B = C / 100
D = Lookup(b , Segmen)
Segmen = 4
Tampilan = D
B = C Mod 100
C = B
B = B / 10
D = Lookup(b , Segmen)
Segmen = 2
Tampilan = D
B = C Mod 10
D = Lookup(b , Segmen)
Segmen = 1
Tampilan = D
Loop
End
Segmen:
Data &H3F , &H06 , &H5B , &H4F , &H66 , &H6D , &H7C , &H07 , &H7F , &H6F
}

2 comments:

  1. asslm. kunjungan balik gan, mantab-mantab nich gan konten2nya. artikel agan nich menarik juga, atur kec motor dc dgn pwm, pakenya bascom ya? kalo saya lebih cenderung ke bhs c entah pake cvavr atw avr-gcc. bisa saling sharing gan ntar...
    ari-bawono.blogspot.com

    ReplyDelete
    Replies
    1. ok bro...saya pake bascom.! bahasa C jga terkadang.!
      saling share ilmu saja

      Delete