Embedded System
Embedded System
Embedded System
#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
int i=0;
x=(arr[x1]|0x80);
i2c_start();
i2c_write(0x70);
i2c_write(arr[x1]|0x80);
i2c_stop();
i2c_start();
i2c_write(0x72);
i2c_write(arr[x2]);
i2c_stop();
void main()
setup_adc_ports( RA0_ANALOG );
setup_adc(ADC_CLOCK_INTERNAL );
while(1)
{set_adc_channel( 0 );
value = read_adc();
i=((value*50)/255);
write_seg(i/10,i%10);
//printf(" %d.%d \n\r",i/10,i%10);
}
PROGRAM
#include<16f877a.h>
#include<stdio.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
void main()
while(1)
a=input(PIN_D0);
b=input(PIN_D1);
printf("\n\r %d %d ",a,b);
b=a&b;
printf("%d",b);
if(b == 0)
output_high(PIN_D4); // MOT
output_high(PIN_D6); // LED:RED
output_low(PIN_D7); // LED:GREEN
else
output_low(PIN_D4); // MOT
output_low(PIN_D6); // LED:GREEN
output_high(PIN_D7); // LED:RED
if(a==0)
output_low(PIN_D6); // LED:GREEN
}
}
PROGRAM
#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
float value;
while(del--);
i2c_start();
i2c_write(0x70);
i2c_write(arr[x1]);
i2c_stop();
i2c_start();
i2c_write(0x72);
i2c_write(arr[x2]);
i2c_stop();
void main()
setup_adc_ports( ALL_ANALOG );
setup_adc(ADC_CLOCK_INTERNAL );
while(1)
{
set_adc_channel( 1);
value = read_adc();
value = value;
i=((int)(value));
i=(i*2);
if(i>=99){i=99;}
write_seg(i/10,i%10);
delay(48000);
}
PROGRAM
#include<16f877a.h>z
#include<stdio.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
void main()
while(1)
}
PROGRAM
#include<16F877A.h>
#use delay(clock=20000000)
void main()
set_tris_b(0xff);
output_b(0xff);
while(1)
a=input_b();
}
PROGRAM
#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
float value;
void main()
while(1)
setup_adc_ports( ALL_ANALOG );
setup_adc(ADC_CLOCK_INTERNAL );
set_adc_channel( 1 );
value = read_adc();
i=(int)(value*0.3);
printf(" %d \n\r",i);
if(i>40)
output_low(PIN_D0);
else if(i<35)
output_high(PIN_D0);
}
PROGRAM
#include<16f877a.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7,stream=GPS)
while(del--);
output_low(pin_E0);
output_low(pin_E1);
delay(500);
output_D(cmd);
delay(500);
output_high(pin_E2);
delay(500);
output_low(pin_E2);
output_high(pin_E0);
output_low(pin_E1);
delay(500);
output_D(dat);
delay(500);
output_high(pin_E2);
delay(500);
output_low(pin_E2);
void lcd_init(void)
lcd_cmd(0X38);
delay(500);
lcd_cmd(0X06);
delay(500);
lcd_cmd(0X0C);
delay(500);
lcd_cmd(0X01);
delay(500);
lcd_cmd(0X80);
delay(500);
for(i=0;w[i]!='\0';i++)
lcd_cmd(add+i);
lcd_dat(w[i]);
delay(500);
{
lcd_dat(((con%1000)/100)+0x30);
lcd_dat(((con%100)/10)+0x30);
lcd_dat((con%10)+0x30);
void print()
lcd_disp(arr,0x80);
void get()
do{;}while(getc()!='R');
void main()
lcd_init();
print();
while(1)
while(1)
get();
lcd_cmd(0xC0);
lcd_con(a1);
}
PROGRAM
#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
int i=0;
void main()
while(1)
setup_adc_ports( ALL_ANALOG );
setup_adc(ADC_CLOCK_INTERNAL );
set_adc_channel( 1 );
value = read_adc();
i=(int)(value/2);
if(i>80)
output_low(PIN_D0);
else
output_high(PIN_D0);
}
PROGRAM
#include<16f877.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
int i=0;
void main()
while(1)
setup_adc_ports( ALL_ANALOG );
setup_adc(ADC_CLOCK_INTERNAL );
set_adc_channel( 1 );
i=(int)(value/2);
if(i>70)
output_low(PIN_D0);
else
output_high(PIN_D0);
}
PROGRAM
#include<16f877a.h>
#include<stdio.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
float value=0;
while(del--);
void set_rtc_time()
i2c_start();
i2c_write(0xa0);
//i2c_write(0x02);
//i2c_write(0x00);
//i2c_write(0x15);
//i2c_write(0x09);
i2c_stop();
void get_rtc_time()
i2c_start();
i2c_write(0xa0);
i2c_write(0x02);
i2c_stop();
i2c_start();
i2c_write(0xa1);
second = i2c_read(0);
i2c_stop();
i2c_start();
i2c_write(0xa0);
i2c_write(0x03);
i2c_stop();
i2c_start();
i2c_write(0xa1);
minute = i2c_read(0);
i2c_stop();
i2c_start();
i2c_write(0xa0);
i2c_write(0x04);
i2c_stop();
i2c_start();
i2c_write(0xa1);
hour = i2c_read(0);
i2c_stop();
void main()
setup_adc_ports( ALL_ANALOG );
setup_adc(ADC_CLOCK_INTERNAL );
set_rtc_time();
while(1)
get_rtc_time();
set_adc_channel( 1 );
value = read_adc();
i=(int)(value/2);
year = 0;
if(minute==0x00)
year=1;
if(minute==0x02)
year=1;
if(minute==0x04)
year=1;
if((year==1)|| (i>70))
output_high(PIN_D0);
output_low(PIN_D0);