Hello!
I need to make a cooling system for a project and to do that I wrote a small code for an ATtiny 25. What I want to do is to measure temperature using LM35 and send out a PWM signal to the base of a transistor, which is going to drive the fan.
The code:
int out = 0; //pin 5 on the chip
float sens_pin = A1; //pin 7 on the chip
int output;
int out_value;
void setup() {
pinMode(out, OUTPUT);
}
void loop() {
output = analogRead(sens_pin);
if(output > 72){
out_value = map(output, 0, 160, 0, 255);
analogWrite(out, out_value);
delay(1);
}
}
I want the cooling system to start when the temperature gets over ~35C.
Is this code good enough?
P.S Sorry for bad English, I'm not a native speaker.