roof55
Newbie level 5
- Joined
- Jan 18, 2016
- Messages
- 9
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 77
const int ledPin1 = 11; // Set pin's in use :
const int ledPin2 = 10;
const int ledPin3 = 9;
const int ledPin4 = 6;
// Variables will change :
int ledState1 = LOW; //
int ledState2 = LOW;
int ledState3 = LOW; // ledState used to set the LED LED STATUS :
int ledState4 = LOW;
long previousMillis = 0; // will store last time LED was updated :
long count = 0;
long interval = 140; // interval at which to blink (milliseconds) lower faster blinks :
void setup() {
// set the digital pin as output :
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
}
void loop()
{
do
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa :
if (ledState1 == LOW ) {
ledState1 = HIGH;
ledState2 = LOW;
}
else {
ledState1 = LOW;
ledState2 = HIGH;
count++;
// set the LED with the ledState of the variable :
}
analogWrite(ledPin1, ledState1);
analogWrite(ledPin2, ledState2);
}
} while (count < 3); //sets how many blinke, GREEN LED :
ledState2 = LOW;
analogWrite(ledPin2, ledState2);
count = 0;
//=========================================================
delay(1000); // PAUSE and sets the time beteewen set green and read
//=========================================================
do
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState3 == LOW) {
ledState3 = HIGH;
ledState4 = LOW;
}
else {
ledState3 = LOW;
ledState4 = HIGH;
count++;
// set the LED with the ledState of the variable:
}
analogWrite(ledPin3, ledState3);
analogWrite(ledPin4, ledState4);
}
} while (count < 2); //sets how many blinke, RED LED :
ledState4 = LOW;
analogWrite(ledPin4, ledState4);
count = 0;
//=========================================================
delay(1400); //sets the time between set green and read
//=========================================================
}
Try inverting the LED outputs in the code, if the code is wrong,, they will come on at 80% brightness, if they stay dim then is a power problem.
Frank
When power on, all LED light up with 100 % brightness level. Ater 3-4 second, the pattern from my Nano started, but only with 20 % brightness. If connected other power supplies, else two 3400 mAh Li-Ion battery in serie connection, just a little change, 30 %.
if (ledState3 == LOW) {
ledState3 = HIGH;
ledState4 = LOW;
}
else {
ledState3 = LOW;
ledState4 = HIGH;
...
count++
}
ledState3=-ledState3;
ledState4=-ledState4;
This suggests that the problem could be related to the firmware, and the standard procedure is mirror the variable that controls the LED at some pin and probe it with an oscilloscope. Anyway, had you added a small ceramic capacitor in parael with the LED ?
Wath value of capacitor?
Did you solve your problem? I am just curious.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?