int LDR = A0;
int LDRValue = 0;
int light_sensitivity = 750;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
LDRValue = analogRead(LDR);
Serial.println(LDRValue);
delay(50);
if (LDRValue < light_sensitivity)
{
analogWrite(13, 100);
}
else
{
analogWrite(13, 200);
}
}
This is the code I got running. Basicly it's hooked up to a lightresistor so when the lights dim, the fan turns on. Like I mentioned earlier it works on another CPU fan I got, the problem might be the PWM frequency.