Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
#include <LCD.C>
#define LCD_ENABLE_PIN PIN_D0
#define LCD_RS_PIN PIN_D1
#define LCD_RW_PIN PIN_D2
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7
#INT_TIMER1
void TIMER1_isr(void)
{
}
#include <lcd.c>
void PWM_init()
{
output_low(PIN_C1); // Set CCP1 output low
output_low(PIN_C2); // Set CCP2 output low
setup_ccp1(CCP_PWM); // Configure CCP1 as a PWM
setup_ccp2(CCP_PWM); // Configure CCP2 as a PWM
setup_timer_2(255,255,1);
}
void main()
{
int fanspeed1=0;
int fanspeed2=0;
unsigned int result1,result2;
float t1,t2;
int k,z=0;
setup_adc_ports(AN0_TO_AN4);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8); //104 ms overflow
PWM_init();
SET_TRIS_B(0xFF);
setup_adc(ADC_CLOCK_INTERNAL );
lcd_init();
while(TRUE)
{
z=0;
set_adc_channel( 0 );
delay_ms(2);
result1=read_adc();
delay_ms(10);
set_adc_channel( 1 );
delay_ms(2);
result2=read_adc();
delay_ms(10);
t1=result1*0.48876;//t=round(val*0.48876);
t2=result2*0.48876;
while(input(PIN_B3))//LCD+ button
{
if(k<2&&z==0)
{
k++;
z++;
}
}
while(input(PIN_B5))//LCD- button
{
if(k>0&&z==0)
{
z++;
k--;
}
}
if(k==0)
{
lcd_gotoxy(1,1);
lcd_putc("TEMP1:");
lcd_gotoxy(1,2);
lcd_putc("TEMP2:");
lcd_gotoxy(7,1);
printf(lcd_putc,"%f",t1);
lcd_gotoxy(7,2);
printf(lcd_putc,"%f",t2);
}
if(k==1)
{
lcd_gotoxy(1,1);
lcd_putc("fFAN1:");
lcd_gotoxy(7,1);
printf(lcd_putc,"%d",fanspeed1);
}
if(k==2)
{
lcd_gotoxy(1,1);
lcd_putc("FAN2:");
lcd_gotoxy(7,1);
printf(lcd_putc,"%d",fanspeed2);
}
while(!input(PIN_B4))
{
/***********
Automatic fan speed limitation by temperature
************/
if(t1>=0 && t1 <=25)
{
fanspeed1=50;
set_pwm1_duty(fanspeed1);
delay_ms(1);
}
else if(t1 >= 25 && t1<= 50)
{
fanspeed1=100;
set_pwm1_duty(fanspeed1);
delay_ms(1);
}
else if(t1 >= 50 && t1<= 75)
{
fanspeed1=150;
set_pwm1_duty(fanspeed1);
delay_ms(1);
}
else
{
fanspeed1=250;
set_pwm1_duty(fanspeed1);
delay_ms(1);
}
//Second fan
if(t2>=0 && t2 <=25)
{
fanspeed2=50;
set_pwm2_duty(fanspeed2);
delay_ms(1);
}
else if(t2 >= 25 && t2<= 50)
{
fanspeed2=100;
set_pwm2_duty(fanspeed2);
delay_ms(1);
}
else if(t2 >= 50 && t2<= 75)
{
fanspeed2=150;
set_pwm2_duty(fanspeed2);
delay_ms(1);
}
else
{
fanspeed2=250;
set_pwm2_duty(fanspeed2);
delay_ms(1);
}
}
// Fan speed controller buttons begin here
while(input(PIN_B4))
{
while(input(PIN_B1))//fan speed increase button
{
if(fanspeed1<250 ) //&& fanspeed2==0
fanspeed1++;
set_pwm1_duty(fanspeed1);
delay_ms(1);
/*
if(speed2>0&&speed1==0)
fanspeed2--;
set_pwm2_duty(speed2);
delay_ms(1);
*/
}
while(input(PIN_B2))//fan speed decrease button
{
if(fanspeed1>0)
fanspeed1--;
set_pwm1_duty(fanspeed1);
delay_ms(1);
/*
if(fanspeed2<250 )//&& fanspeed1==0
fanspeed2--;
set_pwm2_duty(fanspeed2);
delay_ms(1);
*/
}
}
}
}
![]() |
Notes is a web-based application for online 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 14 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