LAMPIRAN 1 PROGRAM KESELURUHAN
#include <mega8535.h> #include <delay.h> #include <stdlib.h>
// Alphanumeric LCD functions #include <alcd.h>
#include <stdbool.h> #include <stdio.h> 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 int maxi=90; //eeprom int mini=10; int maxi = 90;
int mini = 10;
// 1 Wire Bus interface functions #include <1wire.h>
// DS1820 Temperature Sensor functions #include <ds1820.h>
// 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 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;
unsigned long HX711_Read(void) {
unsigned int Get_Weight() {
HX711_Buffer = HX711_Read(); HX711_Buffer = HX711_Buffer/100;
Weight_Shiwu = HX711_Buffer;
if(btn2==0){maxi++; delay_ms(20);} if(btn3==0){maxi--; delay_ms(20);} if(maxi>90){maxi=0; delay_ms(20);} if(maxi<0){maxi=90; delay_ms(20);} lcd_clear();
lcd_gotoxy(0, 0); lcd_putsf("suhu maksimum"); lcd_gotoxy(0, 1); sprintf(buff, "max: %d", maxi);
if(btn2==0){mini++; delay_ms(20);} if(btn3==0){mini--; delay_ms(20);} if(mini>5){mini=0; delay_ms(20);} if(mini<0){mini=90; delay_ms(20);} lcd_clear();
lcd_gotoxy(0, 0); lcd_putsf("suhu maksimum"); lcd_gotoxy(0, 1); sprintf(buff, "min: %d", mini); lcd_puts(buff);
delay_ms(150); }
delay_ms(250);
lcd_clear(); delay_ms(1);
lcd_gotoxy(3, 0); lcd_putsf("udah ya"); delay_ms(2000); lcd_clear();
}
void baca_suhu() {
int i = 0;
ds1820_devices=w1_search(0xf0,ds1820_rom_codes);
// int i = 0;
ds1820_devices=w1_search(0xf0,ds1820_rom_codes);
temp2 = ds1820_temperature_10(&ds1820_rom_codes[i+1][0]); k = '+';
void tampil_lcd(void) {
sprintf(buff, "T1=%c%i.%u", j, temp1/100, temp1%10); lcd_gotoxy(0, 1);
lcd_puts(buff);
sprintf(buff, "T2=%c%i.%u", k, temp2/100, temp2%10); lcd_gotoxy(8, 1);
//lcd_putsf("beratnya adalah");
lcd_gotoxy(0, 0);
//sprintf(text,"%d g",Weight); sprintf(buff,"%.2f kg",berat); lcd_puts(buff);
}
void main(void) {
// Declare your local variables here
DDRA=(0<<DDA7) | (0<<DDA6) | (0<<DDA5) | (0<<DDA4) | (1<<DDA3) | (1<<DDA2) | (1<<DDA1) | (1<<DDA0);
PORTA=(0<<PORTA7) | (0<<PORTA6) | (0<<PORTA5) | (0<<PORTA4) | (0<<PORTA3) | (0<<PORTA2) | (0<<PORTA1) | (0<<PORTA0);
PORTB=(0<<PORTB7) | (0<<PORTB6) | (0<<PORTB5) | (0<<PORTB4) | (0<<PORTB3) | (0<<PORTB2) | (0<<PORTB1) | (0<<PORTB0);
DDRC=(0<<DDC7) | (0<<DDC6) | (0<<DDC5) | (0<<DDC4) | (0<<DDC3) | (0<<DDC2) | (0<<DDC1) | (0<<DDC0);
PORTC=(0<<PORTC7) | (0<<PORTC6) | (0<<PORTC5) | (0<<PORTC4) | (0<<PORTC3) | (0<<PORTC2) | (0<<PORTC1) | (0<<PORTC0);
DDRD=(0<<DDD7) | (0<<DDD6) | (0<<DDD5) | (0<<DDD4) | (0<<DDD3) | (0<<DDD2) | (0<<DDD1) | (0<<DDD0);
PORTD=(0<<PORTD7) | (0<<PORTD6) | (0<<PORTD5) | (0<<PORTD4) | (0<<PORTD3) | (0<<PORTD2) | (0<<PORTD1) | (0<<PORTD0);
//Timer1
// Clock source: T1 pin Falling Edge // Mode: Ph. correct PWM top=0x00FF // OC1A output: Non-Inverted PWM // OC1B output: Non-Inverted PWM // Noise Canceler: Off
// Input Capture on Falling Edge // Timer1 Overflow Interrupt: On // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off
TCCR1A=(1<<COM1A1) | (0<<COM1A0) | (1<<COM1B1) | (0<<COM1B0) | (0<<WGM11) | (1<<WGM10);
TCCR1B=(0<<ICNC1) | (0<<ICES1) | (0<<WGM13) | (1<<WGM12) | (0<<CS12) | (0<<CS11) | (1<<CS10);
//TCCR1A=0x00; // untuk ngetes pin
// 1 Wire Bus initialization // 1 Wire Data port: PORTA // 1 Wire Data bit: 0
// Determine the number of DS1820 devices // connected to the 1 Wire bus
ds1820_devices=w1_search(0xf0,ds1820_rom_codes);
// Alphanumeric LCD initialization // Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // Characters/line: 16 lcd_init(16);
lcd_gotoxy(0, 0); lcd_putsf("Fatya Amy Putri");
lcd_gotoxy(0, 1); lcd_putsf("Bisa ya"); delay_ms(3000); lcd_clear(); delay_ms(100);
Get_Maopi(); while(btn1==1) {
lcd_clear();
//lcd_gotoxy(u, 0); lcd_putsf("Fatya"); lcd_gotoxy(0, 0); lcd_putsf("Fatya");