alexa-tracking
Kategori
Kategori
Home / FORUM / All / Hobby / Hobby & Community /
Hobby Elektronika Digital, MicroController & solder Menyolder gabung sini Yuks
1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/000000000000000002654259/hobby-elektronika-digital-microcontroller-amp-solder-menyolder-gabung-sini-yuks

Hobby Elektronika Digital, MicroController & solder Menyolder gabung sini Yuks

DIGITAL ELECTRONICS HOBBY FORUM




Spoiler for apa aja sih yang dibahas?:


Spoiler for "Hobby Microcontroller Itu Mahal ? Kreativitasmu Itu yg Mahal Gan !":




UPDATE 8/JUNI/2014

DUKUN FUSEBIT AKAN MENGHIDUPKAN IC MU YANG MATI !



Selengkapnya dibahas di sini gan !!

CLINOMETER SEDERHANA MEMANFAATKAN ADC



Selengkapnya dibahas di post berikut




Spoiler for Buka Jika Mau Paket Belajar:


Proyek2 micro yg sudah jadi
Quote:



I.N.D.E.X F.O.R.U.M

Quote:




Biar ngiler, ane kasih contoh hasil karya TS...






Spoiler for Contact TS lewat dimari yahh:



.
Diubah oleh ahocool
Beri apresiasi terhadap thread ini Gan!



Buat yg mau bikin LONELY PAKMAN siapkan bahan2 berikut:

Siapkan Bahan-bahan berikut ini:

1. Micro-AVR ATTiny 2313
2. Breadboard
3. Power suply 5v , atau adaptor 12v dan diregulasi 7805
4. Resistor 10K, 470
5. Tombol push button
6. Xtal 20Mhz + capasitor 22pF
7. Programer AVR
8. Pesawat TV yg nganggur ( jangan sampai bertengkar dengan sodara yg lagi nonton sinetron)

Yang ini skematiknya :




trus kita bahas satu persatu yuk script nya

- INISIALISASI HEADER
Code:

[FONT="Courier New"]//==========LONENLY PAKMAN=======
// by : [email]ahocool@gmail.com[/email]
// [url]http://aisi555.blogspot.com[/url]
//=========== 2012 ===============
#define F_CPU 20000000UL //xtal yg digunakan
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>

#define HSYNC PORTB=0; //H sinkronisasi
#define BLACK PORTB=1; // warna hitem
//deklarasi variable
uint8_t textnya,pakline,arah;
static uint16_t x,y,tick;[/FONT]



- GAMBAR PAKMAN di RAM

Code:

[FONT="Courier New"]char pakman1[12] = // memory penyimapan data gambar pakman

{ //kanan mangap
0b00000000,
0b01111100,
0b11001100,
0b11001000,
0b11110000,
0b11100000,
0b11000000,
0b11100000,
0b11110000,
0b11111000,
0b01111100,
0b00000000,
};


char pakman2[12] =
{ //kanan mingkem
0b00000000,
0b01111100,
0b11001110,
0b11001110,
0b11111110,
0b11111110,
0b11111110,
0b11111110,
0b11000000,
0b11111110,
0b01111100,
0b00000000,
};


char pakman3[12] =

{ //kiri mangap
0b00000000,
0b01111100,
0b01100110,
0b00100110,
0b00011110,
0b00001110,
0b00000110,
0b00001110,
0b00011110,
0b00111110,
0b01111100,
0b00000000,
};


char pakman4[12] =
{ //kiri mingkem
0b00000000,
0b00111100,
0b01100110,
0b01100110,
0b01111110,
0b01111110,
0b01111110,
0b01111110,
0b00000110,
0b01111110,
0b00111100,
0b00000000,
};


char pakman5[12] =

{ //bawah mangap
0b00000000,
0b01111100,
0b11111110,
0b11110010,
0b11110010,
0b11001110,
0b11001110,
0b11000010,
0b10000010,
0b10000010,
0b10000010,
0b00000000,
};


char pakman6[12] =
{ //bawah mingkem
0b00000000,
0b01111100,
0b11111110,
0b11110010,
0b11110010,
0b11111110,
0b10111110,
0b10111110,
0b10111110,
0b10111110,
0b10111100,
0b00000000,
};

char pakman7[12] =

{ //atas mangap
0b00000000,
0b10000010,
0b10000110,
0b10000110,
0b10000110,
0b11011110,
0b10110010,
0b11110010,
0b11111110,
0b01111100,
0b00000000,
};


char pakman8[12] =
{ //atas mingkem
0b00000000,
0b10111100,
0b10111110,
0b10111110,
0b10111110,
0b10111110,
0b11110010,
0b11110010,
0b11111110,
0b01111100,
0b00000000,
};
[/FONT]



kalo dilihat isi memory diatas, akan didapatkan bentuk karakter pakman

0b0 0 0 0 0 0 0 0,
0b0 1 1 1 1 1 0 0,
0b1 1 0 0 1 1 0 0,
0b1 1 0 0 1 0 0 0,
0b1 1 1 1 0 0 0 0,
0b1 1 1 0 0 0 0 0,
0b1 10 0 0 0 0 0,
0b1 1 1 0 0 0 0 0,
0b1 1 1 1 0 0 0 0,
0b1 1 1 1 1 0 0 0,
0b01 1 1 1 1 0 0,
0b0 0 0 0 0 0 0 0,


- TIMER 64 us untuk TV PAL

Code:

[FONT="Courier New"]void timer_init(void){
//inisialisasi timer per rasterline 64us (PAL TV)
TCCR1B |= (1<<WGM12);
TIMSK |= (1<<OCIE1A);
OCR1A = 1280; //64 us dengan xtal 20Mhz, untuk 16Mhz= 1024;
TCCR1B |= (1<<CS10); //full speed[/FONT]
}
[/FONT]



- Interupt Timer Untuk Tampilkan di Layar TV

Code:


[FONT="Courier New"]
ISR (TIMER1_COMPA_vect) {
static uint16_t rasterline=0; //baris
uint16_t a;
uint8_t out=0; // variabel simpan memory byte pakman

HSYNC;

//posisi berdasarkan nilai x,y dengan lebar 12 baris
if( rasterline > (18 + y) && rasterline <= (30 +y) ) {
_delay_us(4);
BLACK;
_delay_us(7);
for(a=0;a<x;a++) asm("nop");
// tampilkan sesuai arah dari pakman
if(arah==0){
if(tick<5000)out= pakman1[pakline];
else out= pakman2[pakline];
}
else if(arah==1){
if(tick<5000)out= pakman3[pakline];
else out= pakman4[pakline];
}
if(arah==2){
if(tick<5000)out= pakman5[pakline];
else out= pakman6[pakline];
}
if(arah==3){
if(tick<5000)out= pakman7[pakline];
else out= pakman8[pakline];
}
//geser bit untuk tampilkan data gambar ke pakman ke TV
PORTB= (out & 0x81) + 1;
out <<=1;
PORTB= (out & 0x81) + 1;
out <<=1;
PORTB= (out & 0x81) + 1;
out <<=1;
PORTB= (out & 0x81) + 1;
out <<=1;
PORTB= (out & 0x81) + 1;
out <<=1;
PORTB= (out & 0x81) + 1;
out <<=1;
PORTB= (out & 0x81) + 1;
out <<=1;
PORTB= (out & 0x81) + 1;


pakline++; //tambahkan index array dari gambar pakman


}

// Vsync ada disini tanpa membedakan genap ganjil
else if( rasterline >= 0 && rasterline < 5 ) {
_delay_us(27);
BLACK;
_delay_us(5);
HSYNC;
_delay_us(27);
BLACK;
} else if( (rasterline >= 5 && rasterline <= 10) ) {
_delay_us(2);
BLACK;
_delay_us(28);
HSYNC;
_delay_us(2);
BLACK;
} else if( rasterline >311-6 ) {
_delay_us(2);
BLACK;
_delay_us(28);
HSYNC;
_delay_us(2);
BLACK;
} else {
_delay_us(3);
BLACK;
pakline=0;
}

rasterline++;
tick++; //variabel timer untuk mangap & mingkem
if(tick >10000) tick=0;


if( rasterline > 311 )rasterline = 0; //maksimum baris/raster

}[/FONT]


- TOMBOL codenya DISINI !

Code:

[FONT="Courier New"]
void tombol(void) // membaca tombol
{
if(bit_is_clear(PIND, PIND3))
{x--;
arah=1;
if(x<1)x=125;
_delay_ms(50);
}

else if(bit_is_clear(PIND, PIND4))
{
x++;
arah=0;
if(x>125)x=1;
_delay_ms(50);
}

else if(bit_is_clear(PIND, PIND5))
{y-=3;
arah=3;
if(y<3)y=280;
_delay_ms(50);
}

else if(bit_is_clear(PIND, PIND6))

{y+=3;
arah=2;
if(y>280)y=0;
_delay_ms(50);
}

} [/FONT]



- PROGRAM UTAMA

Code:

[FONT="Courier New"]
int main() { //Main Program
x=1;
y=13;
arah=0;
DDRD &=~(1<<PD3) & ~(1<<PD4) & ~(1<<PD5) & ~(1<<PD6); //tombol
DDRB = (1<<PB7)|(1<<PB0); //PB0=1K, PB7=470 ohm

timer_init();
sei();

for( ;; )tombol();

}[/FONT]



SELAMAT MENCOBA
GDP Network
© 2019 KASKUS, PT Darta Media Indonesia. All rights reserved
Ikuti KASKUS di