I am new to Arduino but not to Electronics and Micro controllers.
I am looking at using the Pro Mini to control three servos and two flickering LEDs.
I have run into an issue that may be me.
When I try to use PWM on Pins 10,11,12 the LED only lights when the aplitude is set to 255. The LED is connected to GND through a 220R resister.
If I move the LED Resiter to Pin 6 and change the LED_Pin1 Int to pin 6 it all works OK.
What am I missing?
Code Below:
int LED_Pin1 = 10; // Use Pin 10 for the LED1. (Any PWM Pin will work for this.)
int howBright; // Intensity of the LED: [0 = Off], [255 = Brightly Lit]
//
void setup()
{
pinMode(LED_Pin1, OUTPUT); //assigns pin 10 as output for LED1
}
void loop()
{
//light1
howBright = random(128,255); // Change brightness to something between 128 and 255
analogWrite(LED_Pin1, howBright); // Illuminate the LED with the brightness picked
delay(random(0,70)); // Makes LED seem to flicker when on for a random time
[\Code]
Cheers Jim
int LED_Pin1 = 10; // Use Pin 10 for the LED1. (Any PWM Pin will work for this.)
int howBright; // Intensity of the LED: [0 = Off], [255 = Brightly Lit]
//
void setup()
{
pinMode(LED_Pin1, OUTPUT); //assigns pin 10 as output for LED1
}
void loop()
{
//light1
int x = 1;
for (int i = 0; i > -1; i = i + x){
analogWrite(LED_Pin1, i);
if (i == 255) x = -1; // switch direction at peak
delay(10);
}
}
Which should cycle through from off to full on and down to off and so on.