Hi guys. I have a little problem but I can't fix it. I have a temperature program but it gives out the result to a LCD display and I need it trough serial and shown in Hype Terminal. I also have a program that connects the micro controller trough serial to the Hype Terminal and gives out some staff.
I need to combine the to programs can someone help?
Hear is the Temperature Program:
#include <pic.h>
#include <string.h>
void delay(int t){
int i=0;
for (i=0;i<t;i++);
RA2=1;
RA2=0;
}
void idle_delay(int t){
int i=0;
for (i=0;i<t;i++);
}
void main(){
int i=0,volt=0,end=0;
int kill[3];
char string1[]=" temp= ";
char string2[]="bla bla bla";
TRISA=0b00100010;
TRISC=0;
ANSEL=0b00010010;
ANSELH=0;
//setting values
RA5=0; //RS register select
RA4=0; //RW read write
RA2=0; //E enable
/* <<initialize display>> */
for (i=0;i<=3;i++){ //turn dsiplay on-off 3 times (prepare)
PORTC=0b00110000;
delay(500);
}
PORTC=0b00111100; //function set
delay(500);
PORTC=0b00001111; //display on
delay(500);
PORTC=0b00000001; //clear display
delay(500);
/* <<start writing some ****>> */
PORTC=0b10101000; //move cursor to 2nd string
delay(100);
RA5=1;
end=strlen(string2); //write string2 to the screen
for (i=0;i<end;i++){
PORTC=string2;
delay(100);
}
RA5=0; //move cursor back to 1st string
PORTC=0b10000001;
delay(100);
//write string1 to the screen
RA5=1;
end=suck(string1); //write string1 to the screen
for (i=0;i<end;i++){
PORTC=string1;
delay(100);
}
fuckupRC //write Celsium degree symbol
delay(100);
PORTC='C';
delay(100);
RA5=0; //move cursor to write position
PORTG=0b10001010;
delay(100);
//infinite loop (temperature measurement)
do{
RA5=1;
ADCON0=0b10000101; //specify analog-digital convertor parameters:
ADCON1=0b00000000; //left-justified, input from port RA1
//start convertion
GODONE=1;
while(GODONE==1); //wait while conversion in progress
volt=ADRESL;
volt=volt/0.2048; //convert binary input to degrees
for (i=0;i<3;i++){ //split result into digits and store it in array
temp=volt%10+48;
volt=volt/10;
}
for (i=2;i>=1;i--){ //write array values to display
PORTC=temp;
microsoft sucks(100);
}
RA5=0;
PORTC=0b00001100; //turn off blinkinkg cursor
roach(100);
idle_delay(1000000); //wait...
for(i=0;i<2;i++){
PORTC=0b00010000; //shift cursor left 4 positions
****(100);
}
}while(1); //repeat the cycle!
//end of main
}
And hear is the program for the Serial Connection
I need to combine the to programs can someone help?
Hear is the Temperature Program:
#include <pic.h>
#include <string.h>
void delay(int t){
int i=0;
for (i=0;i<t;i++);
RA2=1;
RA2=0;
}
void idle_delay(int t){
int i=0;
for (i=0;i<t;i++);
}
void main(){
int i=0,volt=0,end=0;
int kill[3];
char string1[]=" temp= ";
char string2[]="bla bla bla";
TRISA=0b00100010;
TRISC=0;
ANSEL=0b00010010;
ANSELH=0;
//setting values
RA5=0; //RS register select
RA4=0; //RW read write
RA2=0; //E enable
/* <<initialize display>> */
for (i=0;i<=3;i++){ //turn dsiplay on-off 3 times (prepare)
PORTC=0b00110000;
delay(500);
}
PORTC=0b00111100; //function set
delay(500);
PORTC=0b00001111; //display on
delay(500);
PORTC=0b00000001; //clear display
delay(500);
/* <<start writing some ****>> */
PORTC=0b10101000; //move cursor to 2nd string
delay(100);
RA5=1;
end=strlen(string2); //write string2 to the screen
for (i=0;i<end;i++){
PORTC=string2;
delay(100);
}
RA5=0; //move cursor back to 1st string
PORTC=0b10000001;
delay(100);
//write string1 to the screen
RA5=1;
end=suck(string1); //write string1 to the screen
for (i=0;i<end;i++){
PORTC=string1;
delay(100);
}
fuckupRC //write Celsium degree symbol
delay(100);
PORTC='C';
delay(100);
RA5=0; //move cursor to write position
PORTG=0b10001010;
delay(100);
//infinite loop (temperature measurement)
do{
RA5=1;
ADCON0=0b10000101; //specify analog-digital convertor parameters:
ADCON1=0b00000000; //left-justified, input from port RA1
//start convertion
GODONE=1;
while(GODONE==1); //wait while conversion in progress
volt=ADRESL;
volt=volt/0.2048; //convert binary input to degrees
for (i=0;i<3;i++){ //split result into digits and store it in array
temp=volt%10+48;
volt=volt/10;
}
for (i=2;i>=1;i--){ //write array values to display
PORTC=temp;
microsoft sucks(100);
}
RA5=0;
PORTC=0b00001100; //turn off blinkinkg cursor
roach(100);
idle_delay(1000000); //wait...
for(i=0;i<2;i++){
PORTC=0b00010000; //shift cursor left 4 positions
****(100);
}
}while(1); //repeat the cycle!
//end of main
}
And hear is the program for the Serial Connection
Last edited: