Hi,
I have a pro mini running on 3AA batteries.
I am trying to make a fade loop with a small 3volt bulb ( not LED).
It is working fine except that I cannot get the bulb up to full brightness.
If I measure the voltage it goes up to about 1.4 volts and then will fade back down.
I have tried many different configurations of the code but no luck.
I am trying to get a loop of around 10 seconds and not fading completey to nothing..
I have attached the code which is just the basic fadeloop which has been modified.
Any help appreciated.
/*
Fade
This example shows how to fade an LED on pin 9 using the analogWrite()
function.
The analogWrite() function uses PWM, so if you want to change the pin you're
using, be sure to use another PWM capable pin. On most Arduino, the PWM pins
are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
This example code is in the public domain.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fade
*/
int led = 11; // the PWM pin the LED is attached to
int brightness = 90; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 11 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 11:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 90 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 75 milliseconds to see the dimming effect
delay(1000);
}
I have a pro mini 3.3volt that is connected to a mofset on pin9. I am trying to make a smooth fade loop of approximately 10seconds in each direction - up and down. I had this running succesfully previously on a 12 volt version and I have tried using the same code ( below). It is powering a GOW 3volt bulb. It is sort of working but I cannot get a long slow fade no matter how I juggle the parameters.Will this work? Any suggestions welcome.
I am powering everything with 3AA batteries connected to vcc. I have also tried substituting the mofset IRF 3295 with a transistor TP120 but this doesnt seem to work at all and the bulb just stays on.
const int transistorPin = 9; // connected to the base of the transistor
void setup() {
pinMode(transistorPin, OUTPUT);
}
void loop() {
for (int brightness = 0; brightness < 255; brightness++) {
analogWrite(transistorPin, brightness);
delay(30);
}
delay(2000);
for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(transistorPin, brightness);
delay(30);
}
delay(2000);
}
Did you mean IRF3205? That mosfet is not suited to be driving by a 3.3V signal. You need to use a TTL level mostfet, typically IRLxxxx. You should be able to use a regular transistor, depending on how much current your bulb actually uses.
Your two or more topics on the same or similar subject have been merged.
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.