A little background:
So I made a stand-alone Arduino using the atmega328-p QFN chip that incorporates NPN transistors in order to drive some LED's.
PCB layout:
I'm having an issue where when using the Millis() function, the LED stays dim after a digitalWrite LOW is sent to the output of the microcontroller.
The strange part is that when using "delay();", The LED turns completely off instead of staying slightly dim when using Millis().
LED's when using delay:
LED's when using millis()
Here is the code that is using Millis()
unsigned long BIAUXms = 0;
unsigned long currentms=0;
void setup() {
// put your setup code here, to run once:
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
BIAUX();
currentms= millis();
}
void BIAUX(){
if(currentms-BIAUXms>=50){
digitalWrite(8,HIGH);
}
if(currentms-BIAUXms>=100){
digitalWrite(8,LOW);
}
if(currentms-BIAUXms>=150){
digitalWrite(8,HIGH);
}
if(currentms-BIAUXms>=200){
digitalWrite(8,LOW);
}
if(currentms-BIAUXms>=250){
digitalWrite(8,HIGH);
}
if(currentms-BIAUXms>=450){
digitalWrite(8,LOW);
}
//Swtich Leds
if(currentms-BIAUXms>=500){
digitalWrite(7,HIGH);
}
if(currentms-BIAUXms>=550){
digitalWrite(7,LOW);
}
if(currentms-BIAUXms>=600){
digitalWrite(7,HIGH);
}
if(currentms-BIAUXms>=650){
digitalWrite(7,LOW);
}
if(currentms-BIAUXms>=700){
digitalWrite(7,HIGH);
}
if(currentms-BIAUXms>=900){
digitalWrite(7,LOW);
BIAUXms=currentms;
}
}
Here is the code that is using delay()
void setup() {
// put your setup code here, to run once:
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(7,HIGH);
delay(50);
digitalWrite(7,LOW);
delay(50);
digitalWrite(7,HIGH);
delay(50);
digitalWrite(7,LOW);
delay(50);
digitalWrite(7,HIGH);
delay(175);
digitalWrite(7,LOW);
delay(50);
digitalWrite(8,HIGH);
delay(50);
digitalWrite(8,LOW);
delay(50);
digitalWrite(8,HIGH);
delay(50);
digitalWrite(8,LOW);
delay(50);
digitalWrite(8,HIGH);
delay(175);
digitalWrite(8,LOW);
delay(50);
}
Any help would be greatly appreciate!