Adu Mikro : Arduino Vs Atmega8535 (Ronde 2)

Setelah ‘adu mikro’ ronde 1 dengan materi membaca sensor suhu, sekarang kita mulai ronde 2, membuat jam digital. Arduino yang kita minta maju tanding si Arduino UNO, sedangkan dari kubu AVR kita pilih Atmega8535.

 

Membuat jam digital dengan Arduino dan juga Atmega8535. Teng – teng – teng ……. Mulai Arduino dulu ya …
Kita siapkan sebuah board Arduino UNO, modul RTC (Real Time Clock) DS1307 dan sebuah LCD.

Jam Digital Arduino

Langsung ke programnya ya :

#include <Wire.h>
#include <DS1307.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.clear();
  lcd.print(“Jam”);
  lcd.setCursor(0,1);
  RTC.start();
}

void loop()
{
  lcd.clear();
  lcd.print(RTC.get(DS1307_HR,true));
  lcd.print(“:”);
  lcd.print(RTC.get(DS1307_MIN,false));
  lcd.print(“:”);
  lcd.print(RTC.get(DS1307_SEC,false));
  lcd.setCursor(0,1);
  lcd.print(RTC.get(DS1307_DATE,false));
  lcd.print(“/”);
  lcd.print(RTC.get(DS1307_MTH,false));
  lcd.print(“/”);
  lcd.print(RTC.get(DS1307_YR,false));  
  delay(1000);
}

 

Nih hasilnya :

Jam Digital dg Arduino

Sekarang giliran Atmega8535, pertama biar disiapkan hardware jam digital : mikrokontroler Atmega8535, LCD dan modul RTC DS1307.

Jam Digital dengan AVR

 

Lanjut bikin program dengan bahasa C (CVAVR) :

#include <mega8535.h>
#include <delay.h>
#include <stdio.h>
#asm
   .equ __i2c_port=0x12 ;PORTd
   .equ __sda_bit=7
   .equ __scl_bit=6
#endasm
#include <i2c.h>
#include <ds1307.h>
#asm
   .equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd.h>
unsigned char h,m,s,d,t,y;
char buffer[16];

void main(void)
{
i2c_init();
rtc_init(0,0,0);
rtc_set_time(10,23,15);
rtc_set_date(3,7,15);     
delay_ms(100);

lcd_init(16);
lcd_clear();
lcd_putsf(“Date=”);
lcd_gotoxy(0,1);
lcd_putsf(“Time=”);   
while (1)
      {
      rtc_get_date(&d,&t,&y);    
      rtc_get_time(&h,&m,&s);
      sprintf( buffer,”%02d/%02d/%02d”,d,t,y);         
      lcd_gotoxy(5,0);
      lcd_puts(buffer);
      sprintf( buffer,”%02d:%02d:%02d”,h,m,s);         
      lcd_gotoxy(5,1);
      lcd_puts(buffer);
      delay_ms(900);         
      };
}

 

Kalau pakai BASCOM-AVR :

$regfile = “m8535.dat”
$crystal = 16000000
$lib “mcsbyte.lbx”
$lib “ds1307clock.lib”
Config Sda = Portd.7
Config Scl = Portd.6
Const Ds1307w = &HD0                                        ‘
Const Ds1307r = &HD1
Config Clock = User
Dim Weekday As Byte
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.0
Config Lcd = 16 * 2
Cursor Off
Cls
Lcd “Date=”
Lowerline
Lcd “Time=”

Do
     Locate 1 , 6
     Lcd Date$
     Locate 2 , 6
     Lcd Time$
     Waitms 900
Loop
Getdatetime:
  I2cstart
  I2cwbyte Ds1307w
  I2cwbyte 0
  I2cstart
  I2cwbyte Ds1307r
  I2crbyte _sec , Ack
  I2crbyte _min , Ack
  I2crbyte _hour , Ack
  I2crbyte Weekday , Ack
  I2crbyte _day , Ack
  I2crbyte _month , Ack
  I2crbyte _year , Nack
  I2cstop
  _sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
  _day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year)
Return

Hasilnya jam digital dengan Atmega8535 :

Jam Digital dg AVR ATmega8535

Gimana ? Kira – kira lebih enakan Arduino atau Atmega8535 ?

 

5 thoughts on “Adu Mikro : Arduino Vs Atmega8535 (Ronde 2)

  • July 26, 2015 at 10:07 am
    Permalink

    mas boleh saya minta library ds1307 untuk arduino. soalnya udah download error terus mas . makasih sebelumnya mas

    Reply
    • July 29, 2015 at 3:41 pm
      Permalink

      ambil disini mas lengkap :

      Reply
      • September 28, 2015 at 9:13 pm
        Permalink

        kang minta library ds1307 untuk arduino, soalnya error terus

        Reply
        • December 15, 2015 at 11:07 am
          Permalink

          Bisa sedot disini mas Asep :

          Reply
  • July 31, 2015 at 9:34 am
    Permalink

    bisa tolong di upload di komenan ga mas , buat prakrek mas !! he

    Reply

Leave a Reply

WhatsApp chat
%d bloggers like this: