Thanks for your replies, Ive taken a look and started to write some code. Ive wired up my 24v LED via a IRF840 MOSFET
it sort of works but with strange results... it dimms to about 70-80% then back up to 100% using the following code:
int ledPin = 11; // LED connected to digital pin 9
void setup() {
// nothing happens in setup
}
void loop() {
// fade in from min to max in increments of 5 points:
for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
wreckitsteve:
Thanks for your replies, Ive taken a look and started to write some code. Ive wired up my 24v LED via a IRF840 MOSFET
it sort of works but with strange results... it dimms to about 70-80% then back up to 100% using the following code:
int ledPin = 11; // LED connected to digital pin 9
void setup() {
// nothing happens in setup
}
void loop() {
// fade in from min to max in increments of 5 points:
for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
not sure why it wont fade to off!
any ideas?
Sorry about the comment confusion, i forget to edit it. When i put the code you said in setup it just stays on about about 50% bright.
An IRF840 is not a logic level mosfet.
The 5volt logic of an Arduino might or might not turn it on sufficiently.
You might have been lucky that the second fet had a lower gate threshold voltage.
Leo..
Wawa:
An IRF840 is not a logic level mosfet.
The 5volt logic of an Arduino might or might not turn it on sufficiently.
You might have been lucky that the second fet had a lower gate threshold voltage.
Leo..