Hi All
My first post here - I'm a beginner so show mercy .
I am programming the Attiny85 with SpenceKonde core via my Uno - no problems there. I've been able to use the Attiny to blink an LED, sense a button press and activate other parts of my power supply circuit - again no problems.
I am having an issue though with controlling the 12v brushless fan speed with the AnalogWrite function. Here is the schematic of the controller:
When I measure the voltage sent to the fan I get 11.7v irrespective of the analogWrite(fanPin, value?) I use - the fan is either off or at full speed. Here's the code FWIW - I've removed all the other code to only focus on the fan control:
const byte tempPin = 2;Â // temp input pin from LM35
const byte fanPin = 0;Â // drive pin for the fan
const byte LEDPin = 4; // drive pin for the LED
const byte powerPin = 3; //Â drive pin for PSU on off
const byte buttonPin = 1; // button input pin
int temp = 0;Â // start temp read zero
const byte tempMin = 82;Â // the temperature to start the fan; (40 degC x 0.01 V/degC / 0.0048828175 V/bit)
const byte tempMax = 123;Â // the maximum operational temperature allowed before power supply shutdown (60 degC x 0.01 V/degC / 0.0048828175 V/bit)
void setup() // do this once at startup
{Â
 pinMode(fanPin, OUTPUT);
 pinMode(LEDPin, OUTPUT);
 pinMode(tempPin, INPUT);
 pinMode(powerPin, OUTPUT);
 pinMode(buttonPin, INPUT_PULLUP);
}
void loop()
{Â
 temp = analogRead(tempPin);
 analogWrite(fanPin, map(temp, tempMin, tempMax, 32, 255));
Â
 // irrespective of what value I substitute for MAP fucntion I can't get the fan to run slower
}
Any ideas?