Led blinking irregularly - is my device damaged

Hi!

I'm quite new when concerning Arduino although I work in IT since many years.

Lately I decided to start some fun with Arduino and for that I bought a cheap Arduino uno r3 from aliexpress (CH340 Atmega 328p). After having terrible problems with installing it under Linux I decided to compile and run simple led blinking project (one of typical examples from net). However led was blinking irregularly thus not as I would expect when using delay function.

Finally I compiled the following code:

int counter = 0;

void setup() {
  Serial.begin(9600);

 pinMode(10,OUTPUT);
 pinMode(13,OUTPUT);
}

void loop() {
   digitalWrite(10, HIGH);
   digitalWrite(13, HIGH);
   delay(500);
   digitalWrite(10, LOW);
   digitalWrite(13, LOW);
   
   delay(5000);

   Serial.println(counter++);
}

I would expect that the counter will increase one by one in the regular time intervals. However time intervals seems to be partially random and the order of counter is the following (one of examples):

0
1
2
3
4
113
114
115
0
1
2
3
4
5
39
40
41
83
99
115
116
117
167

In my humble opinion this module doesn't work correctly. Am I doing sth wrong or is that a problem with arduino device? Any reset, recompiling etc. don't help.

Thanks for suggestions.

P.S. Serial port speed is set the same at computer as for arduino program.

Hi @ken-wawa ,

I agree. The results look quite strange.

The easiest way to check what your sketch should be doing is the simulation platform Wokwi:

See here: https://wokwi.com/projects/388191341984986113

I assume that you have chosen the correct board in the Arduino IDE ...

How do you have your LEDs wired up? Do you have current limiting resistors installed? Typically a 220 ohm resistor.

What happens if you comment out all 4 of your digitalWrite() calls inside loop(). If that fixes the problem, you probably have something wired up wrong and pulling to much current.

int counter = 0;

void setup() {
  Serial.begin(9600);

 //pinMode(10,OUTPUT);
 //pinMode(13,OUTPUT);
}

void loop() {
   //digitalWrite(10, HIGH);
   //digitalWrite(13, HIGH);
   delay(500);
   //digitalWrite(10, LOW);
   //digitalWrite(13, LOW);
   
   delay(5000);

   Serial.println(counter++);
}

Concerning board, I selected Arduino Uno. Should I select sth different?

Concerning resistor, I use 330ohm resistor.

Earlier I tried to use D13 on board led and it was the same. Blinking was irregular.

I commented all led instructions, leaving only delays and println and I have the same, the counter doesn't count one by one, but in random way. Example:

1
2
16519

0
1
0
1
2
3
0
1
2

Might it be somehow related with using incorrect libraries? Does Arduino have any watch dog system?

I find sth that this device should be visible as WeMos D1. However when installing esp2866com according to this manual: Installing — ESP8266 Arduino Core 3.1.2-21-ga348833 documentation installation is fine but when reruning arduino ide, i can't see new devices to select.

Well, I find a problem with weMos D1 library. The description at the page given above is incorred. If I call the directory 1.8.6 instead of esp8266 then IDE starts seeing the libraries. However for all Wemos D1, compiling is fine, but when sending it to device I get error.

Moreover I added static to counter variable, but it didn't change anything (as static probably here doesn't matter).

However when i look on Wemos D1 devices on Internet, they look fully different than mine thus I doubt if it was the right idea. Please have a look on my device: https://pl.aliexpress.com/item/1005006038084112.html

Concluding everything shows that my device is damaged. I think it might be sth wrong with memory.

???

I confirm. My device was damaged (=working incorrectly). With other devices I bought I didn't observe such a strange behaviour.

  • 19th alphabetically.
  • Sith ancient order of the Force devoted to the dark side.
  • abbreviation for " supercalifragilisticexpialidocious" (probably this one)
  • much like "ne" for the too-long-to-type "any"

I think at this juncture there's no point in trying to catch up!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.