Hellow my fellow Arduino programmers, i have a little question.
For a school project i am designing a little set up that displays the temperature that i measure with a ntc. And i want to do this with a arduino.
i have written two pieces of arduino codes i want to combine them, and on that point i need your help. what i want for result is that my temperature is displayed on my 2* 7 led display.
first piece of code:
//#define PD5 0b00100000
//#define PD6 0b00100000
#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>//voor dtostrf
#include "AInOut.h"
#include "serial.h"
#define BAUD_RATE 9600
double Volt;
int Temp;
char strTemp[15];
char *strT;
int main (void)
{
//PWMD5D6_init();
ADC_init();
serial_init(BAUD_RATE);
while (1){
Temp=(5.0 * ADC_read(0) * 100.0)/1024.0; //NB waarde afh. van weerstand en NTC
//Temp=Temp/6.036; //NB waarde afhankelijk van weerstand en NTC type
strT=dtostrf(Temp,4,2,strTemp);
strcat (strT ," grd C\n\r");
serial_print(strTemp);
_delay_ms(100);
}
return 0;
}
this piece of code is for the temperature
the next one:
#include <avr/io.h>
#include <stdlib.h>//voor dtostrf
#include <math.h>
#include "serial.h"
#define BAUD_RATE 9600
int temp;
int T1;
int T2;
int getal;
;
double getalnw;
char waarde;
char berekening;
char mystr[10];
int s;
int main(void)
{
serial_init(BAUD_RATE);
DDRB = 0xFF;
DDRC = 0xFF;
DDRD = 0xFF;
while (1) {
serial_print("geef getal NB reset voor nieuw getal: ");//
temp=serial_readdbl();
serial_print("\r\n");
//temp=serial_get();
// serial_put(temp);
// serial_print("\r\n");
T1 = temp / 10;
getalnw=T1;
dtostrf(getalnw, 6,2,mystr);//6 cijfers totaal en 3 voor de '.'
serial_print(mystr);
T2 = temp - (10*T1);
getalnw=T2;
dtostrf(getalnw, 6,2,mystr);//6 cijfers totaal en 3 voor de '.'
serial_print(mystr);
if (T2==0){PORTD = 0b00000000;PORTC = 0b00011000;}
if (T2==1){PORTD = 0b11100100;PORTC = 0b00011000;}
if (T2==2){PORTD = 0b10010000;PORTC = 0b00010000;}
if (T2==3){PORTD = 0b11000000;PORTC = 0b00010000;}
if (T2==4){PORTD = 0b01100100;PORTC = 0b00010000;}
if (T2==5){PORTD = 0b01001000;PORTC = 0b00010000;}
if (T2==6){PORTD = 0b00001000;PORTC = 0b00010000;}
if (T2==7){PORTD = 0b11100000;PORTC = 0b00011000;}
if (T2==8){PORTD = 0b00000000;PORTC = 0b00010000;}
if (T2==9){PORTD = 0b01000000;PORTC = 0b00010000;}
if (T1==0)PORTB = 0b11111111;
if (T1==1)PORTB = 0b11111001;
if (T1==2)PORTB = 0b11100100;
if (T1==3)PORTB = 0b11110000;
if (T1==4)PORTB = 0b11010001;
if (T1==5)PORTB = 0b11010010;
if (T1==6)PORTB = 0b11000010;
if (T1==7)PORTB = 0b11111000;
if (T1==8)PORTB = 0b11000000;
if (T1==9)PORTB = 0b11010000;
}
return 0;
}
this piece of code is for controling the leds on the display.
i hope you can give me some advice for combining these two so my program will display the temperature without using the computer so it is a stand alone.
Greetings Martijn