0% found this document useful (0 votes)
25 views

Flowchart Kontrol Utama

The document contains a flowchart and code for a microcontroller program. The flowchart shows the program executing a normal routine when button 1 is pressed, and stopping that routine when button 2 is pressed. The code defines routines for a normal function that outputs characters and sets port values in a loop, and a main function that runs the normal routine when button 1 is pressed and stops it when button 2 is pressed by changing the port values.

Uploaded by

Mufidah Muf
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Flowchart Kontrol Utama

The document contains a flowchart and code for a microcontroller program. The flowchart shows the program executing a normal routine when button 1 is pressed, and stopping that routine when button 2 is pressed. The code defines routines for a normal function that outputs characters and sets port values in a loop, and a main function that runs the normal routine when button 1 is pressed and stops it when button 2 is pressed by changing the port values.

Uploaded by

Mufidah Muf
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Flowchart Kontrol Utama

normal

n=0 ; n<=120 ;n++ ;

n==0

A4B0C2
0x84

n==7

A4B0C3
0xc4
A4B0C2
0x04

n==10
0

A5B0C0
0x05

n==13

A0B0C0
0x00

n==15
4

A4B0C2
0x40

n==27

n==30

A4B0C2
0x81

n==32

A4B0C2
0x52

n==37

A4B0C2
0x8a

B
1

2
A

n==40

A4B0C2
0x92

n==67

A4B0C2
0xd2

n==70

A4B0C2
0x12

n==87

A4B0C2
0x52

n==90

A4B0C2
0x92

n==95

A4B0C2
0x48

n==98

A4B0C2
0x94

n==117
7

Pb_off=1

end

A4B0C2
0x9c
N=120

start

Pb_on=1

PORTB.0=1
&&PORTB.1=0

Pb_off=1

end

PORTB.0=1
PORTB.1=0

Normal()

PORTB.0=1
PORTB.1=0

Program Kontrol Utama


Chip type
: ATmega16
Program type
: Application
Clock frequency : 12,000000 MHz
Memory model
: Small
External RAM size : 0
Data Stack size : 256
*****************************************************/
#include <mega16.h>
// Standard Input/Output functions
#include <stdio.h>
#include <delay.h>
#define pb_off PINC.1
#define pb_on PINC.0
// Declare your global variables here
void normal(void)
{
int n;
for(n=0;n<=120;n++)
{
if(n==0)
{putchar('A')putchar('4');
putchar('B');putchar('0');
putchar('C');putchar('2');
PORTA=0x84;}
if(n==7)
{putchar('A');putchar('4');
putchar('B');putchar('0');
putchar('C');putchar('3');
PORTA=0xc4;}
if(n==10)
{putchar('A');putchar('4');
putchar('B');putchar('0');
putchar('C');putchar('0');
PORTA=0x04;}
if(n==13)

{putchar('A');putchar('5');
putchar('B');putchar('0');
putchar('C');putchar('0');
PORTA=0x05;}
if(n==15)
{putchar('A');putchar('0');
putchar('B');putchar('0');
putchar('C');putchar('0');
PORTA=0x00;}
if(n==27)
{putchar('A');putchar('0');
putchar('B');putchar('0');
putchar('C');putchar('1');
PORTA=0x40;}
if(n==30)
{putchar('A');putchar('1');
putchar('B');putchar('0');
putchar('C');putchar('2');
PORTA=0x81;}
if(n==32)
{putchar('A');putchar('2');
putchar('B');putchar('0');
putchar('C');putchar('2');
PORTA=0x82;}
if(n==37)
{putchar('A');putchar('2');
putchar('B');putchar('1');
putchar('C');putchar('2');
PORTA=0x8a;}
if(n==40)
{putchar('A');putchar('2');
putchar('B');putchar('2');
putchar('C');putchar('2');
PORTA=0x92;}
if(n==67)
{putchar('A');putchar('1');
putchar('B');putchar('2');
putchar('C');putchar('3');
PORTA=0xD2;}

if(n==70)
{putchar('A');putchar('2');
putchar('B');putchar('2');
putchar('C');putchar('0');
PORTA=0x12;}
if(n==87)
{putchar('A');putchar('2');
putchar('B');putchar('2');
putchar('C');putchar('1');
PORTA=0x52;}
if(n==90)
{putchar('A');putchar('2');
putchar('B');putchar('2');
putchar('C');putchar('2');
PORTA=0x92;}
if(n==95)
{putchar('A');putchar('3');
putchar('B');putchar('2');
putchar('C');putchar('2');
PORTA=0x93;}
if(n==98)
{putchar('A');putchar('4');
putchar('B');putchar('2');
putchar('C');putchar('2');
PORTA=0x94;}
if(n==117)
{putchar('A');putchar('4');
putchar('B');putchar('3');
putchar('C');putchar('2');
PORTA=0x9c;}
if(pb_off.1==1)
{n=120;}
delay_ms(1000);
}
}

void main(void)

{
PORTA=0x00;
DDRA=0xff;
PORTB=0x00;
DDRB=0xff;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0x00;
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x4D;
while (1)
{
// Place your code here
if(pb_on==1)
{
PORTB.0=1;
PORTB.1=0;
}
if(PORTB.0==1 && PORTB.1==0)
{
normal();
}
if(PINC.1==1)
{
PORTB.0=0;
PORTB.1=1;
}
};
}

You might also like