Rancang Bangun Alat Pengontrol Volume Air dan Aerator Pada Kolam Budidaya Udang Menggunakan Mikrokontroler
Lampiran 1
#include
#include
#include
#include
#define selo PORTD.7
#define pompa PORTD.6
#define aero PORTD.5
unsigned int count = 0;
unsigned char jarak;
unsigned char jrk;
unsigned char tinggi;
unsigned int tng;
unsigned long vol;
float vol1;
unsigned char buff1[16];
unsigned char buff2[16];
unsigned int baca_jarak()
{
count = 0;
PORTB.0 = 1;
delay_us(10);
PORTB.0 = 0;
while(PINB.1 == 0){};
while(PINB.1 == 1) {count++;};
//jarak = count*0.091;
jarak = count;
jarak = jarak / 5.5;
return jarak;
}
Universitas Sumatera Utara
/*
float vol()
{
float vol1 = jarak*5*5;
return vol1;
} */
void main (void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0xF1;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0xFF;
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
TCCR1A=0x00;
TCCR1B=0x02;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
Universitas Sumatera Utara
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
MCUCR=0x00;
MCUCSR=0x00;
UCSRB=0x00;
SFIOR=0x00;
ADCSRA=0x00;
SPCR=0x00;
TWCR=0x00;
lcd_init(16);
while(1)
{
//vol();
//lcd_gotoxy(0, 0);
lcd_putsf("tinggi air");
jrk = baca_jarak();
tinggi = 31 - jrk;
tng = tinggi*100;
vol = tng*5*5;
vol1 = vol;
if (tinggi < 19)
{PORTD.6 = 1;
//pompa
{lcd_gotoxy(11, 0); lcd_putsf("P_ON");}
PORTD.7 = 0;
//selo
{lcd_gotoxy(11, 1); lcd_putsf("S_OFF");}
PORTD.5 = 0;
//aero
{lcd_gotoxy(0, 1); lcd_putsf("A_ON");}
Universitas Sumatera Utara
}
if(tinggi > 21)
{PORTD.6 = 0;
//pompa
{lcd_gotoxy(11, 0); lcd_putsf("P_OFF");}
PORTD.7 = 1;
//selo
{lcd_gotoxy(11, 1); lcd_putsf("S_ON");}
PORTD.5 = 0;
//aero
{lcd_gotoxy(0, 1); lcd_putsf("A_ON");}
}
if ( tinggi > 0 )
{
PORTD.5 = 1;
//aero on
{lcd_gotoxy(0, 1); lcd_putsf("A_ON");
lcd-gotoxy(11, 0); lcd_putsf("P_OFF"):
lcd_gotoxy(11, 1); lcd_putsf("S_OFF"):
}
}
sprintf(buff1, "T=%d", tinggi);
lcd_gotoxy(6, 1);
lcd_puts(buff1);
//sprintf(buff2, "V=%d L ", vol1);
sprintf(buff2, "V=%.0fml
lcd_gotoxy(0, 0);
", vol1);
lcd_puts(buff2);
delay_ms(1000);
lcd_clear(); delay_ms(10);
}
}
Universitas Sumatera Utara
Lampiran 2
Universitas Sumatera Utara
Lampiran 3
Universitas Sumatera Utara
Universitas Sumatera Utara
#include
#include
#include
#include
#define selo PORTD.7
#define pompa PORTD.6
#define aero PORTD.5
unsigned int count = 0;
unsigned char jarak;
unsigned char jrk;
unsigned char tinggi;
unsigned int tng;
unsigned long vol;
float vol1;
unsigned char buff1[16];
unsigned char buff2[16];
unsigned int baca_jarak()
{
count = 0;
PORTB.0 = 1;
delay_us(10);
PORTB.0 = 0;
while(PINB.1 == 0){};
while(PINB.1 == 1) {count++;};
//jarak = count*0.091;
jarak = count;
jarak = jarak / 5.5;
return jarak;
}
Universitas Sumatera Utara
/*
float vol()
{
float vol1 = jarak*5*5;
return vol1;
} */
void main (void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0xF1;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0xFF;
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
TCCR1A=0x00;
TCCR1B=0x02;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
Universitas Sumatera Utara
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
MCUCR=0x00;
MCUCSR=0x00;
UCSRB=0x00;
SFIOR=0x00;
ADCSRA=0x00;
SPCR=0x00;
TWCR=0x00;
lcd_init(16);
while(1)
{
//vol();
//lcd_gotoxy(0, 0);
lcd_putsf("tinggi air");
jrk = baca_jarak();
tinggi = 31 - jrk;
tng = tinggi*100;
vol = tng*5*5;
vol1 = vol;
if (tinggi < 19)
{PORTD.6 = 1;
//pompa
{lcd_gotoxy(11, 0); lcd_putsf("P_ON");}
PORTD.7 = 0;
//selo
{lcd_gotoxy(11, 1); lcd_putsf("S_OFF");}
PORTD.5 = 0;
//aero
{lcd_gotoxy(0, 1); lcd_putsf("A_ON");}
Universitas Sumatera Utara
}
if(tinggi > 21)
{PORTD.6 = 0;
//pompa
{lcd_gotoxy(11, 0); lcd_putsf("P_OFF");}
PORTD.7 = 1;
//selo
{lcd_gotoxy(11, 1); lcd_putsf("S_ON");}
PORTD.5 = 0;
//aero
{lcd_gotoxy(0, 1); lcd_putsf("A_ON");}
}
if ( tinggi > 0 )
{
PORTD.5 = 1;
//aero on
{lcd_gotoxy(0, 1); lcd_putsf("A_ON");
lcd-gotoxy(11, 0); lcd_putsf("P_OFF"):
lcd_gotoxy(11, 1); lcd_putsf("S_OFF"):
}
}
sprintf(buff1, "T=%d", tinggi);
lcd_gotoxy(6, 1);
lcd_puts(buff1);
//sprintf(buff2, "V=%d L ", vol1);
sprintf(buff2, "V=%.0fml
lcd_gotoxy(0, 0);
", vol1);
lcd_puts(buff2);
delay_ms(1000);
lcd_clear(); delay_ms(10);
}
}
Universitas Sumatera Utara
Lampiran 2
Universitas Sumatera Utara
Lampiran 3
Universitas Sumatera Utara
Universitas Sumatera Utara