void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//here setting the pin to high output
char DDRK;
char y;
//address
DDRK=0x107;
y=&DDRK;
//data
DDRK|=(1<<DDK1);//setting pin to output
// seeting as input *dir&=~(1<<dir);
volatile char *ger;
ger=0x30;
*ger=0xFF;
}
void hel(volatile char *out){
*out|=(1<<PORTF0);
}
void fd(volatile char *ou){
*ou|=(1<<PORTK1);
}
void og(volatile char *out){
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
//here directly accessing the analog read using library
int analogReadValue = analogRead(A1);
float celsius = 1 / (log(1 / (1023. / analogReadValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
if (celsius>22.0){
*out|=(1<<PORTK2);
}
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.println(" °C");
}
void set(volatile char *out){
*out|=(1<<PORTK0);
}
void reset(volatile char *out){
*out&=~0xFF;
}
void loop() {
// put your main code here, to run repeatedly:
volatile char *out;
out=0x108;
volatile char *her;
her=0x31;
unsigned int res=0;
res=5;
switch(res){
case 1:
set(out);
break;
case 2:
reset(out);
break;
case 3:
fd(out);
break;
case 4:
hel(her);
break;
case 5:
og(out);
break;
default:
set(out);
break;
}
}