You are on page 1of 9

9/17/2020

Flowchart &
Pseudocode

Flowchart

Terminator
Process Data I/O

Arrow

Y N Subroutine
Connector
Decision

Sistem uP - KDPBA Antonius Wibowo 2

1
9/17/2020

Flowchart

Sistem uP - KDPBA Antonius Wibowo 3

Struktur Program 1/8

 Simple sequence
 Kontrol dan iterasi:
 If-then-else
 If-then
 Case
 While-do loop
 Repeat-until
 For

Sistem uP - KDPBA Antonius Wibowo 4

2
9/17/2020

Struktur Program 2/8

Simple sequence
Pseudocode:
Statement(s) 1
Statement(s) 1 Statement(s) 2
Example:
Get data sample
Add 7
Store in memory location
Statement(s) 2
Flowchart  gambar, singkat
Pseudocode = a brief descriptions of the flow
of the code

Sistem uP - KDPBA Antonius Wibowo 5

Struktur Program 3/8

Yes Condition No
?

Statement(s) 1 Statement(s) 2

Sistem uP - KDPBA Antonius Wibowo 6

3
9/17/2020

Struktur Program 4/8

If-then
Pseudocode:
If condition then
Condition Statement(s)
? Example:
If hungry then
Yes get food

Statement(s) No

Sistem uP - KDPBA Antonius Wibowo 7

Struktur Program 5/8

Yes Monday No
?

Read books Yes Tuesday


? No

...
Read Yes Sunday
magazines
?

Read
newspaper

Sistem uP - KDPBA Antonius Wibowo 8

4
9/17/2020

Struktur Program 5/8

Case, expressed as multiple if-then-else


Pseudocode:
Yes Monday
?
No
If Monday then
Read books
Read books Yes Tuesday
? No
else if Tuesday then
... Read magazines
Read
magazines
Yes Sunday
?
else if Wednesday then
Read tabloids
Read
newspaper …
else if Sunday then
Read newspaper

Sistem uP - KDPBA Antonius Wibowo 9

Struktur Program 6/8

Case
Pseudocode:
Case expression of
1: Statement(s) 1
2: Statement(s) 2
...
N: Statement(s) N
Example:
Case day of
Monday:
Read books
Tuesday:
Read magazines
Wednesday:
Read tabloids

Sunday:
Read newspaper
Sistem uP - KDPBA Antonius Wibowo 10

5
9/17/2020

Struktur Program 7/8

While-do loop
Pseudocode:
While condition do

Statement(s)
Condition
? Example:
While money lasts
Yes No Eat supper out
Go to movie
Statement(s) Take taxi home

Sistem uP - KDPBA Antonius Wibowo 11

Struktur Program 8/8

Repeat-until
Pseudocode:
Repeat
Statement(s)
Statement(s) No
Until condition
Example:
Repeat
Get data sample
Condition Add 7
? Store result in memory
Wait 1 hour
Yes Until 24 samples taken

Sistem uP - KDPBA Antonius Wibowo 12

6
9/17/2020

Struktur Program 9/9


Pseudocode:
Kondisi awal
Do Statement(s)
And Increment kondisi
Until kondisi

Example:
for (inisialisasi; kondisi; increment)
{
Tugas;
}

#include<avr/io.h>
I/O Programming
START

unsigned char i;
unsigned int k; INISIALISASI PORT
void delay_ms (); & ENABLE PULL-UP

main(void) BACA PORT A


{
/* Define pull-ups and set outputs high */
/* Define directions for port pins */
PORT A,
DDRA = 0XF0; BIT 0 = 1 ?
PORTA = 0X0F;
DDRC = 0XFF;
PORT C:
SET BIT 7,5,3,1
while(1) CLEAR BIT 6,4,2,0
{ i = PINA; /* Read port pins */
if (i == 0x01)
DELAY
{ PORTC = 0XAA;
delay_ms();
PORTC = 0X55; PORT C:
SET BIT 6,4,2,0
delay_ms(); CLEAR BIT 7,5,3,1
}
}
DELAY
return(0);
}

7
9/17/2020

8
9/17/2020

7-segment

You might also like