swtbbert
Newbie level 5
- Joined
- Nov 24, 2013
- Messages
- 10
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 11
- Activity points
- 54
Hi!
I've designed a thermometer using RF by pic16f877a, my problem is how con i read the value to the second pic and to display it, please some1 can help..
my codes for TX
I've designed a thermometer using RF by pic16f877a, my problem is how con i read the value to the second pic and to display it, please some1 can help..
my codes for TX
Code:
// LCD module connections
sbit LCD_RS at RB2_bit; // rs connection at rb2
sbit LCD_EN at RB3_bit; // en connection at rb3
sbit LCD_D4 at RB4_bit; // d4 connection at rb4
sbit LCD_D5 at RB5_bit; // d5 connection at rb5
sbit LCD_D6 at RB6_bit; // d6 connection at rb6
sbit LCD_D7 at RB7_bit; // d7 connection at rb7
sbit LCD_RS_Direction at TRISB2_bit; // data direction setting
sbit LCD_EN_Direction at TRISB3_bit; // data direction setting
sbit LCD_D4_Direction at TRISB4_bit; // data direction setting
sbit LCD_D5_Direction at TRISB5_bit; // data direction setting
sbit LCD_D6_Direction at TRISB6_bit; // data direction setting
sbit LCD_D7_Direction at TRISB7_bit; // data direction setting
// End LCD module connections
float volt,temp; // VARIABLE FOR READING AND STORING VALUES
unsigned char volt_char[15]; // STRING (ARRAY OF CHARACTERS) VARIABLE FOR LCD DISPLAY
void init() // initialization routine definition (register initializations are done here)
{
adcon1=0 ; // configure all portA and portE chanels as analog
trisc=0x00;
portc=0;
trise = 0x2;
cmcon = 7;
lcd_init() ; // initialize lcd connections
lcd_cmd(_lcd_clear) ;// clear lcd
lcd_cmd(_lcd_cursor_off);// turne off hte cursor
}
void main() // main routine definition
{
init(); // call the initialization routine
lcd_out(1,3,"Temperature"); // show <voltmeter> on 3rd column of first row of lcd
lcd_chr(2,12,223);
lcd_out(2,13,"C"); // show <V> on 15th column of 2nd row of lcd
uart1_Init(9600);
delay_ms(100);
while(1) // step into infinite loop
{
volt=adc_read(2); // take the analog signal value fron analog channel 2 (latched to ra2 pin)
volt=volt/1024; // extracting voltage value from 10 bit resolution
volt=volt*5000; // extracting voltage value from 10 bit resolution
temp=volt/10; // CONVERTING THE VOLTAGE VALUE TO CENTIGRADE SCALE
floattostr(temp,volt_char);// convert the voltage value to string for
//showing on lcd
lcd_out(2,4,volt_char); // show the string (voltage value) on
//lcd(2nd row,1st column)
uart1_Write_Text(volt_char);
UART1_Write(10);
UART1_Write(13);
delay_ms(200);
..........
for RX
// LCD module connections
sbit LCD_RS at RB2_bit; // rs connection at rb2
sbit LCD_EN at RB3_bit; // en connection at rb3
sbit LCD_D4 at RB4_bit; // d4 connection at rb4
sbit LCD_D5 at RB5_bit; // d5 connection at rb5
sbit LCD_D6 at RB6_bit; // d6 connection at rb6
sbit LCD_D7 at RB7_bit; // d7 connection at rb7
sbit LCD_RS_Direction at TRISB2_bit; // data direction setting
sbit LCD_EN_Direction at TRISB3_bit; // data direction setting
sbit LCD_D4_Direction at TRISB4_bit; // data direction setting
sbit LCD_D5_Direction at TRISB5_bit; // data direction setting
sbit LCD_D6_Direction at TRISB6_bit; // data direction setting
sbit LCD_D7_Direction at TRISB7_bit; // data direction setting
// End LCD module connections
unsigned char volt_char[15];
char txt;
char uart_rd;
float volt, temp;
void main() // main routine definition
{
uart1_Init(4800);
delay_ms(100);
cmcon = 7;
adcon1=0 ; // configure all portA and portE chanels as analog
trisc = 0x00;
portc = 0;
lcd_init() ; // initialize lcd connections
lcd_cmd(_lcd_clear) ;// clear lcd
lcd_cmd(_lcd_cursor_off);// turne off hte cursor
lcd_out(1,3,"Temperature"); // show <temperature> on 3rd column of first row of
lcd_chr(2,12,223);
lcd_out(2,13,"C"); // show <C> on 13th column of 2nd row of lcd
do
{
if(uart1_Data_Ready()){
uart_rd = uart1_Read();
ByteToStr(uart_rd,volt_char);
lcd_out(2,4,volt_char);
uart1_Write(volt_char);
}
}while(1);
}
Last edited by a moderator: