Rancang Bangun Pengaturan Suhu dan Pengukuran Berat Badan pada Inkubator Bayi Berbasis MikrokontrolerATMega8535

55

LAMPIRAN

Universitas Sumatera Utara

56

LAMPIRAN 1 PROGRAM KESELURUHAN

#include
#include
#include
// Alphanumeric LCD functions
#include
#include
#include
unsigned char buff[33];
//bagian HX711
#define HX711_SCK PORTB.7
#define HX711_DT PINB.6

#define HIGH 1
#define LOW 0
//bagian tombol dan relay
#define btn1 PINA.0
#define btn2 PINA.1
#define btn3 PINA.2
#define Relay1 PORTB.0
#define Relay2 PORTB.1
//eeprom
//eeprom
int maxi
int mini

int maxi=90;
int mini=10;
= 90;
= 10;

// 1 Wire Bus interface functions
#include

// DS1820 Temperature Sensor functions
#include
// connected to the 1 Wire bus
#define MAX_DS1820 8
unsigned char ds1820_devices;
unsigned char ds1820_rom_codes[MAX_DS1820][9];
// Declare your global variables here
int baca_DS1, baca_DS2;
int temp1, temp2;

Universitas Sumatera Utara

57

int j, k;
//float W1, W2;
long HX711_Buffer = 0;
long Weight_Maopi = 0,Weight_Shiwu = 0;
int Weight = 0;


//float HX711_Buffer = 0;
//float Weight_Maopi = 0,Weight_Shiwu = 0;
//float Weight = 0;
float berat=0;

int kp = 250;
void kontrol_Kp()
{
int Propor, Error, pwm;
Error = abs(baca_DS2 - baca_DS1);
Propor = kp*Error;
pwm = Propor;
if (Error