sistem mikrokontroler - dinus.ac.iddinus.ac.id/repository/docs/ajar/u-4.pdf · output pada port a...

17
Sistem Mikrokontroler FE UDINUS 8 Maret 2013 Minggu ke 3

Upload: vuminh

Post on 14-Aug-2019

221 views

Category:

Documents


0 download

TRANSCRIPT

Sistem Mikrokontroler FE UDINUS

8 Maret 2013

Minggu ke 3

2

7 Segment

3

4

6

Contoh

PORTA=0x00; DDRA=0xFF;

PORTA=0xFF; DDRA=0xFF;

PORTA=0xFF; Output pada port A akan bernilai “1” PORTA=0x00; Output pada port A akan bernilai “0”

10

Led nyala-mati

while (1) { // Place your code here PORTC=0xFF; delay_ms(500); }; }

11

while (1) { // Place your code here PORTC=0xFF; };

while (1) { // Place your code here PORTC=0x01; };

12

while (1) { // Place your code here PORTC=0x10; };

while (1) { // Place your code here PORTC=0x01; };

13

while (1) { // Place your code here PORTC=0x3E; };

while (1) { // Place your code here PORTC=0xDE; };

while (1) { PORTD=0x01; delay_ms(500); PORTD=0x02; delay_ms(500); PORTD=0x04; delay_ms(500); PORTD=0x08; delay_ms(500); PORTD=0x10; delay_ms(500); PORTD=0x20; delay_ms(500); PORTD=0x40; delay_ms(500); PORTD=0x80; delay_ms(500); };

while (1) { PORTD= 1; delay_ms(250); PORTD= 2; delay_ms(250); PORTD= 4; delay_ms(250); PORTD= 8; delay_ms(250); PORTD= 16; delay_ms(250); PORTD= 32; delay_ms(250); PORTD= 64; delay_ms(250); PORTD= 128; delay_ms(250); } };

while (1) { PORTD=0b00000001; delay_ms(100); PORTD=0b00000010; delay_ms(100); PORTD=0b00000100; delay_ms(100); PORTD=0b00001000; delay_ms(100); PORTD=0b00010000; delay_ms(100); PORTD=0b00100000; delay_ms(100); PORTD=0b01000000; delay_ms(100); PORTD=0b10000000; delay_ms(100); };

while (1) { /* if (kanan ==0b00000001) kanan = 0b10000000; // geser kekiri else kanan >>= 1; PORTD = kanan; delay_ms(100); */ if (kanan ==0b00000001) kanan = 0b10000000; //geser kekanan else kiri <<= 1; PORTD = kiri; delay_ms(100); }; }

while (1) { // Place your code here PORTD=PINA; }; }

while (1) { if(PINA.0==1) {PORTD=0x18;} if(PINA.1==1) {PORTD=0XFF;} if(PINA.2==1) {PORTD=0x42;} if(PINA.3==1) {PORTD=0x61;} } }

TERIMA KASIH

18