Sei sulla pagina 1di 14

PRAKTIKUM 1

#include <mega128.h>
#include <stdio.h>

void main(void)
{
int a;
PORTA=0x00;
DDRA=0xFF;
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: On
// USART0 Transmitter: Off
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0x10;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x47;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

PORTA=0x00;

while (1)
{
// Place your code here
a=getchar();
if(a=='1')
PORTA.0=1;
if(a=='0')
PORTA.0=0;
};
}


Hasil Simulasi dengan menggunakan Proteus ( ISIS )
























PRAKTIKUM 2

#include <mega128.h>
// Standard Input/Output functions
#include <stdio.h>

// Declare your global variables here

void main(void)
{
int a;
PORTA=0x00;
DDRA=0xFF;
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: On
// USART0 Transmitter: Off
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0x10;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x47;

PORTA=0x00;

while (1)
{
// Place your code here
a=getchar();
if(a=='1')
PORTA=0x03;
if(a=='2')
PORTA=0x0C;
if(a=='3')
PORTA=0x30;


};
}

Hasil Simulasi dengan menggunakan Proteus ( ISIS )


Tombol 2 ditekan Tombol 3 ditekan






















PRAKTIKUM 3

RECEIVER

#include <mega128.h>

// Standard Input/Output functions
#include <stdio.h>

// Declare your global variables here

void main(void)
{
// Declare your local variables here
int a;
PORTA=0x00;
DDRA=0xFF;

// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: On
// USART0 Transmitter: Off
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0x10;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x47;

PORTA=0x00;

while (1)
{
// Place your code here
a=getchar();
if(a=='1')
PORTA.0=1;
if(a=='0')
PORTA.0=0;

};
}

TRANSMITER

#include <mega128.h>
#include <stdio.h>

// Declare your global variables here

void main(void)
{
PORTA=0xFF;
DDRA=0x00;
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: Off
// USART0 Transmitter: On
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0x08;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x47;


while (1)
{
// Place your code here
if(PINA.0==0)
putchar('1');
if(PINA.1==0)
putchar('0');

};
}

Hasil Simulasi dengan menggunakan Proteus ( ISIS )

Saat Push Button 0 ditekan


Saat Push Button 1 ditekan





















PRAKTIKUM 4

TRANSMITER

#include <mega128.h>

#include <stdio.h>

void main(void)
{
PORTA=0xFF;
DDRA=0x00;
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: Off
// USART0 Transmitter: On
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0x08;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x47;


while (1)
{
// Place your code here
if(PINA.0==0)
putchar('1');
if(PINA.1==0)
putchar('2');
if(PINA.2==0)
putchar('0');

};
}

RECEIVER

#include <mega128.h>

#include <stdio.h>


void main(void)
{
int a;
PORTA=0x00;
DDRA=0xFF;
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: On
// USART0 Transmitter: Off
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0x10;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x47;

PORTA=0x00;

while (1)
{
// Place your code here
a=getchar();
if(a=='1')
PORTA=0x05;
if(a=='2')
PORTA=0x0A;
if(a=='0')
PORTA=0x00;

};
}


Hasil Simulasi dengan menggunakan Proteus ( ISIS )

Saat Pb1 ditekan maka motor Counter Clock Wise

Saat Push Button 2 ditekan maka motor CW Saat Push Button 3 ditekan maka motor mati




















PRAKTIKUM 5

TRANSMITER

#include <mega128.h>

#include <stdio.h>

void main(void)
{
PORTA=0xFF;
DDRA=0x00;
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: Off
// USART0 Transmitter: On
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0x08;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x47;


while (1)
{
// Place your code here
if(PINA.0==0)
putchar('1');
if(PINA.1==0)
putchar('2');
if(PINA.2==0)
putchar('0');

};
}

RECEIVER

#include <mega128.h>

#include <stdio.h>


void main(void)
{
int a;
PORTA=0x00;
DDRA=0xFF;
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: On
// USART0 Transmitter: Off
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0x10;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x47;

PORTA=0x00;

while (1)
{
// Place your code here
a=getchar();
switch(a){
case'1':PORTA=0x05;break;
case'2':PORTA=0x0A;break;
case'0':PORTA=0x00;break;
}
};
}

Hasil Simulasi dengan menggunakan Proteus ( ISIS )

Saat Pb1 ditekan maka motor Counter Clock Wise

Saat Push Button 2 ditekan maka motor CW Saat Push Button 3 ditekan maka motor mati




















Kesimpulan
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

Potrebbero piacerti anche