Hello,
I hope this is something that I am overlooking but I have a simple sketch that does an analogWrite to set the brightness of an LED. When I run it powered via USB it runs with the proper delays and everything is timed correctly. Although when I plug in a 9V 1A power supply in it doesn't run as expected. My question is why is there a difference in the sequence when I use the external power supply? My power supply's voltage seems to be OK, my only thought is that the amperage is too high. From my understanding the PS will only supply the current that is asked for so it shouldn't be the PS current.
Here is a video of what is happening.
http://youtu.be/qrAX4ok1jnkHere is my sketch.
/*
Test Program to dim a UV LED
*/
typedef struct{
byte brightVal; // Value to set the LED to
int waitVal; // The integer part of the wait value
int x10; // The power (*10^) value of the wait value.
} pUnit;
const byte numSteps=6;
const byte thePin=11;
pUnit Pattern[numSteps] =
{
{10,5,2},
{40,5,2},
{90,5,2},
{150,5,2},
{255,2,3},
{0,1,4}
};
void setup(){
pinMode(thePin,OUTPUT);
}
void loop(){
byte i;
for(i=0;i<numSteps;i++){ //Step through each of the steps.
analogWrite(thePin,Pattern[i].brightVal); //Set the brightness
delay(Pattern[i].waitVal*pow(10,Pattern[i].x10)); //Wait based on waitVal*10^x10
}
}
Thank you.
-Andy