NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <son_haberlesme.h>

#include <stdio.h>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use fast_io(a)
#use delay(clock=4000000)

#include <math.h>

#define ENTER PIN_D3
#define ASAGI PIN_D1
#define YUKARI PIN_D0
#define ESC PIN_D2
#use fast_io(b)

#define use_portb_lcd TRUE
#include <lcd.c>

int8 i=0,j=0 ,menu=0,menu_say=0,set_m=0,m_sn=0,sn=0,dkk=0 , set_mina=0,set_maxa=0,hata=0,kacaka=0;
unsigned int sicaklik_kay=0,sicaklik1=0,bin[10],bin1[10],oct=0,octalNum1=0;
int16 setmin_v,setmax_v;
int deciNum, octalNum;

#define ONE_WIRE_PIN PIN_C0
#include <DS1302.c>



float sicaklik;



int b , binaryNumber[10] , k=1, l, quotient,sayi1=0;

long int decn,q,dn=0,m,a;
char s;






void onewire_reset()

{
output_low(ONE_WIRE_PIN);
delay_us( 500 );
output_float(ONE_WIRE_PIN);
delay_us( 500 );
output_float(ONE_WIRE_PIN);
}

void onewire_write(int data)
{
int count;
for (count=0; count<8; ++count)
{
output_low(ONE_WIRE_PIN);
delay_us( 2 );
output_bit(ONE_WIRE_PIN, shift_right(&data,1,0));
delay_us( 60 );
output_float(ONE_WIRE_PIN);
delay_us( 2 );
}
}

int onewire_read()
{
int count, data;
for (count=0; count<8; ++count)
{
output_low(ONE_WIRE_PIN);
delay_us( 2 );
output_float(ONE_WIRE_PIN);
delay_us( 8 );
shift_right(&data,1,input(ONE_WIRE_PIN));
delay_us( 120 );
}
return( data );
}

float ds1820_read()
{
int8 busy=0, temp1, temp2;
signed int16 temp3;
float result;
onewire_reset();
onewire_write(0xCC);
onewire_write(0x44);
while (busy == 0)
busy = onewire_read();
onewire_reset();
onewire_write(0xCC);
onewire_write(0xBE);
temp1 = onewire_read();
temp2 = onewire_read();
temp3 = make16(temp2, temp1);
result = (float) temp3 / 16.0;
return(result);
}




#int_timer0 // Timer0 kesmesi
void timer0_kesme () // Kesme fonksiyonu ismi
{
set_timer0(60); // TMR0 değeri belirleniyor
i++; // i değeri 1 arttırılıyor
if (i==16) // i değeri X'ye eşitse
{
sn++;
m_sn++;
i=0;
}
else if (sn>59){dkk++;sn=0;}
else if (dkk>59){dkk=0;}
}


void lcd_bilgi ()
{
LCD_gotoxy(1,1);
printf(lcd_putc,"MICROISLEMCILER");

LCD_gotoxy(5,2);
printf(lcd_putc,"PROJESI");

}





void binary_donusum()
{

sicaklik=(int)ds1820_read();
delay_ms(1000);


quotient=(int)sicaklik;


while (quotient!=0)
{
binaryNumber[k]=(int) quotient %2;
quotient=quotient/2;
k++;
}

printf(lcd_putc,"fBinary:");
sayi1=0;
for(l=k-1;l>0;l--)
{

lcd_gotoxy(8+sayi1,1);
printf(lcd_putc,"%d", binaryNumber[l]);
sayi1++;

}
k=1;
l=0;

}


void decimaltoOctal()
{
sicaklik=(int)ds1820_read();
delay_ms(1000);
deciNum=(int)sicaklik;

int octalNum = 0, countval = 1;


while (deciNum != 0) {
// decimals remainder is calculated
int remainder = deciNum % 8;

// storing the octalvalue
octalNum += remainder * countval;

// storing exponential value
countval = countval * 10;
deciNum /= 8;
}
lcd_gotoxy(1,1);
printf(lcd_putc,"fOCTAL:%d", octalNum);
octalNum1=octalNum;
}




void decimaltohexadecimal()
{
sicaklik=(int)ds1820_read();
delay_ms(1000);
decn=(int)sicaklik;

q=decn;


for(a=q;a>0;a=a/16)
{
b = a % 16;
if( b < 10)
b =b + 48; else
b = b + 55;
dn=dn*100+b;
}

for(m=dn;m>0;m=m/100)
{
s=m % 100;
lcd_gotoxy(1,1);
printf(lcd_putc,"%c", s);
}

}





void main()
{

lcd_init();



setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256); // Timer0 ayarları yapılıyor
set_timer0(60); // TMR0 değeri belirleniyor
enable_interrupts(INT_timer0); // int_timer0 kesmesini aktif yapar
enable_interrupts(GLOBAL); // Aktif edilen kesmelere izin ver

set_tris_a(0x01);

//set_tris_b(0xff);

set_tris_d(0xff);


//setup_WDT(WDT_1152MS);


while(TRUE)
{




if (menu==0) {lcd_bilgi (); }


if (input(ENTER)&&(menu==0))
{
printf(lcd_putc,"f");
menu=1;
menu_say=0;

}

if ((menu>0)&&(set_m==0))
{

switch(menu_say)
{

case 0:
lcd_gotoxy(1,1);
printf(lcd_putc,">1-SICAKLIK ");
lcd_gotoxy(1,2);
printf(lcd_putc," 2-OGRENCI");
if (input(ENTER)&&(m_sn>0)) {m_sn=0;set_m=1;printf(lcd_putc,"f");} //set menüye git
break;
case 1:
lcd_gotoxy(1,1);
printf(lcd_putc," SICAKLIK");
lcd_gotoxy(1,2);
printf(lcd_putc,">2-OGRENCI");
if (input(ENTER)&&(m_sn>0)) {m_sn=0;set_m=1;printf(lcd_putc,"f");} //set menüye git
break;
case 2:
lcd_gotoxy(1,1);
printf(lcd_putc,">3-BINARY GONDER");
lcd_gotoxy(1,2);
printf(lcd_putc," 4-ASCII DECIMAL");
if (input(ENTER)&&(m_sn>0)) {m_sn=0;set_m=1;printf(lcd_putc,"f");} //set menüye git
break;
case 3:
lcd_gotoxy(1,1);
printf(lcd_putc," 3-BINARY GONDER");
lcd_gotoxy(1,2);
printf(lcd_putc,">4-ASCII DECIMAL");
if (input(ENTER)&&(m_sn>0)) {m_sn=0;set_m=1;printf(lcd_putc,"f");} //set menüye git
break;
case 4:
lcd_gotoxy(1,1);
printf(lcd_putc,">5-ASCII HEXADEC");
lcd_gotoxy(1,2);
printf(lcd_putc," 6-ASCII OCTAL ");
if (input(ENTER)&&(m_sn>0)) {m_sn=0;set_m=1;printf(lcd_putc,"f");} //set menüye git
break;
case 5:
lcd_gotoxy(1,1);
printf(lcd_putc," 5-ASCII HEXADEC");
lcd_gotoxy(1,2);
printf(lcd_putc,">6-ASCII OCTAL ");
if (input(ENTER)&&(m_sn>0)) {m_sn=0;set_m=1;printf(lcd_putc,"f");} //set menüye git
break;
}




if(input(ASAGI)&&(menu_say<5))
{
while(input(ASAGI));
++menu_say;
//if(menu_say==5)
// menu_say=0;
}
else if(input(YUKARI)&&(menu_say>0))
{
while(input(YUKARI));
--menu_say;
//if(menu_say==0)
// menu_say=0;
}


if (input(Esc)&&(menu==1)&&(m_sn>1))
{
printf(lcd_putc,"f");
menu=0;
}

}

if ((menu>0)&&(set_m==1))
{

switch(menu_say)
{
case 0:

sicaklik = ds1820_read();
delay_ms(350);

lcd_gotoxy(1,1);
printf(lcd_putc," SICAKLIK:%3.1f C", sicaklik);
sicaklik1=(unsigned)sicaklik;

write_eeprom (0,sicaklik1);

lcd_gotoxy(1,2); // saat Koyulacak !!!
// printf(lcd_putc," KAYDEDILIYOR...");

if(input(ASAGI)&&(set_maxa>0))
{
while(input(ASAGI));
--set_maxa;
}
else if(input(YUKARI)&&(set_maxa<20))
{
while(input(YUKARI));
++set_maxa;
}


break;

case 1:
lcd_gotoxy(1,1);
printf(lcd_putc," SERHAT KAS ");
lcd_gotoxy(1,2);
printf(lcd_putc," 170224078");
//bilgileri kaydet

if(input(ENTER)) {write_eeprom (1,set_mina);}
if(input(ASAGI)&&(set_mina>0))
{
while(input(ASAGI));
--set_mina;
}
else if(input(YUKARI)&&(set_mina<20))
{
while(input(YUKARI));
++set_mina;
}
break;

case 2:


binary_donusum();

// bin[10]=binaryNumber[l];


// if(input(ENTER)) {write_eeprom (2,bin1);}


// bin1[10]=read_eeprom(2);
for(l=k-1;l>0;l--)
{

lcd_gotoxy(8+sayi1,1);
printf(lcd_putc,"%d", binaryNumber[l]);
sayi1++;

}

if(input(ENTER)) {write_eeprom (2,binaryNumber[l]);}


lcd_gotoxy(1,2);
printf(lcd_putc,"Kaydedildi.",);

if(input(ASAGI)&&(setmax_v>0))
{
while(input(ASAGI));
--setmax_v;
}
else if(input(YUKARI)&&(setmax_v<250))
{
while(input(YUKARI));
++setmax_v;
}
break;

case 3:
sicaklik = ds1820_read();
delay_ms(350);

sicaklik1=(unsigned int)sicaklik;

write_eeprom (3,sicaklik1);



sicaklik_kay=read_eeprom(3);
lcd_gotoxy(1,1);
printf(lcd_putc,"SICAKLIK DEC:%d",sicaklik_kay);

lcd_gotoxy(1,2);
printf(lcd_putc,"Kaydedildi.");


if(input(ASAGI)&&(setmin_v>0))
{
while(input(ASAGI));
--setmin_v;
}
else if(input(YUKARI)&&(setmin_v<250))
{
while(input(YUKARI));
++setmin_v;
}
break;


case 4:
// lcd_gotoxy(1,1);
// printf(lcd_putc,"KAY:%d",read_eeprom(2));
decimaltoOctal();
oct=(unsigned)octalNum1;

write_eeprom (5,oct);


lcd_gotoxy(1,1);
printf(lcd_putc,"==%u",octalNum1);
lcd_gotoxy(1,2);
printf(lcd_putc,"=%u",read_eeprom(5));


// decimaltohexadecimal();
// decimaltohexadecimal();

if(input(ASAGI)&&(kacaka>0))
{
while(input(ASAGI));
--kacaka;
}
else if(input(YUKARI)&&(kacaka<10))
{
while(input(YUKARI));
++kacaka;
}
break;



case 5:

decimaltoOctal();
oct=(unsigned)octalNum1;

write_eeprom (5,oct);


lcd_gotoxy(1,2);
printf(lcd_putc,"Kaydedildi:%u",read_eeprom(5));



if(input(ASAGI)&&(hata>0))
{
while(input(ASAGI));
--hata;
}
else if(input(YUKARI)&&(hata<10))
{
while(input(YUKARI));
++hata;
}
break;
}
if ((input(ESC))&&(m_sn>0)) {set_m=0;m_sn=0; }



}


// while(input(pin_a0)) {restart_wdt();}


// sleep();

}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.