- Pada menubar file Click New file, kemudian akan muncul halaman berikur.
- Pilih project, kemudian pilih yes pada form konfirmasi.
- Kemudian akan muncul Form berikut untuk memilih Tipe chip yang akan digunakan. Disini kita akan menggunakan tipe chip ATmega.
- Disini saya menggunakan chip atmega32A dengan crystal sebesar 12.000 Mhz
- Kemudian kita akan mengatur PORT D sebagai keluaran untuk menyalakan LED, maka kita akan melakukan settingan sebagai berikut.
- Kemudian langkah selanjutnya ialah dengan menyimpan program yang telah dibaut dalam satu folder yang sama, dengan melakukan generate, save and exit. Kemudian simpan file tersebut dengan nama yang sama sebanyak 4 kali. Seperti langkah berikut ini. Pertama buat folder dulu untuk menyimpan file C dan projectnya.
Oh iya sebelumya saya akan memberikan skematiknya di bwah ya :
This program was produced by the
CodeWizardAVR V2.05.3 Standard
Automatic Program Generator
© Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project : Police Light
Version : 2
Date : 08-Feb-2016
Author : Yohanes Irvan Dwi N
Company : Y-I Elektronik
Comments: (www.the-elektronika.blogspot.com)
Chip type : ATmega32A
Program type : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 512
*****************************************************/
#include <mega32a.h>
#include <delay.h>
// Declare your global variables here
void flipflop()
{
PORTD = 0b11110000;
delay_ms(15);
PORTD = 0b00000000;
delay_ms(30);
PORTD = 0b11110000;
delay_ms(15);
PORTD = 0b00001111;
delay_ms(15);
PORTD = 0b00000000;
delay_ms(30);
PORTD = 0b00001111;
delay_ms(15);
PORTD = 0b11110000;
delay_ms(15);
PORTD = 0b00000000;
delay_ms(30);
PORTD = 0b11110000;
delay_ms(15);
PORTD = 0b00001111;
delay_ms(15);
PORTD = 0b00000000;
delay_ms(30);
PORTD = 0b00001111;
delay_ms(15);
}
void AllLedOn()
{
PORTD = 0b11111111;
delay_ms(10);
PORTD = 0b00000000;
delay_ms(10);
PORTD = 0b11111111;
delay_ms(10);
PORTD = 0b00000000;
delay_ms(10);
PORTD = 0b11111111;
delay_ms(10);
PORTD = 0b00000000;
delay_ms(10);
PORTD = 0b11111111;
delay_ms(10);
PORTD = 0b00000000;
delay_ms(10);
PORTD = 0b11111111;
delay_ms(10);
PORTD = 0b00000000;
delay_ms(10);
PORTD = 0b11111111;
delay_ms(10);
PORTD = 0b00000000;
delay_ms(10);
PORTD = 0b11111111;
delay_ms(10);
PORTD = 0b00000000;
delay_ms(10);
PORTD = 0b11111111;
delay_ms(10);
}
void BlitzKanan()
{
PORTD = 0b00001111;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00001111;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00001111;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00001111;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00001111;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00001111;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
}
void BlitzKiri()
{
PORTD = 0b11110000;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11110000;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11110000;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11110000;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11110000;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11110000;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
}
void BlitzKanan22()
{
PORTD = 0b00110011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00110011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00110011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00110011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00110011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00110011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
}
void BlitzKiri22()
{
PORTD = 0b11001100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11001100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11001100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11001100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11001100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11001100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
}
void BlitzTengah()
{
PORTD = 0b00111100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00111100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00111100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00111100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00111100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b00111100;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
}
void BlitzPinggir()
{
PORTD = 0b11000011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11000011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11000011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11000011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11000011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
PORTD = 0b11000011;
delay_ms(6);
PORTD = 0b00000000;
delay_ms(6);
}
void main(void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0xFF;
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
MCUCR=0x00;
MCUCSR=0x00;
TIMSK=0x00;
UCSRB=0x00;
ACSR=0x80;
SFIOR=0x00;
ADCSRA=0x00;
SPCR=0x00;
TWCR=0x00;
while (1)
{
// Place your code here
// Mode kedip standar semua led
AllLedOn();
// Mode flip flop
flipflop();
flipflop();
// Mode kedip standar semua led
AllLedOn();
AllLedOn();
// Mode kedip cepat setiap sisi kiri dan kanan
BlitzKanan();
BlitzKiri();
BlitzKanan();
BlitzKiri();
BlitzKanan();
BlitzKiri();
BlitzKanan();
BlitzKiri();
// Mode kedip standar semua led
AllLedOn();
AllLedOn();
// Mode kedip cepat setiap 2 led pada sisi kiri dan kanan
BlitzKanan22();
BlitzKiri22();
BlitzKanan22();
BlitzKiri22();
BlitzKanan22();
BlitzKiri22();
BlitzKanan22();
BlitzKiri22();
// Mode kedip standar semua led
AllLedOn();
AllLedOn();
// Mode kedip cepat setiap sisi tengan dua led dan sisi pinggir 2 led
BlitzPinggir();
BlitzTengah();
BlitzPinggir();
BlitzTengah();
BlitzPinggir();
BlitzTengah();
BlitzPinggir();
BlitzTengah();
}
}
hehehehe ok, mungkin hanya ini yang bisa saya berikan kepada kalian yang mau bereksperimen, semoga bermanfaat ya. hehehehe SALAM ELEKTRONIKA