chrisl
  • Member for 4 years
  • Last seen this week
My code seems to be a train wreck
40 votes

The error cascade is caused by the missing opening curly bracket { at the start of the thirtyBullets() function. This causes the function name to be not declared and also the following function calls ...

View answer
Why is it considered bad practice to use the 'new' keyword in Arduino?
Accepted answer
17 votes

Most Arduinos (like the Uno or Nano) have very few RAM, thus you first need to make sure that you never allocate too much memory. Dynamically allocating memory can also lead to heap fragmentation (...

View answer
Arduino voltage misunderstanding
Accepted answer
12 votes

Every pin gives you 5V on HIGH, yes, but these voltages don't add up. Voltages are always measured between two points. In electronics we are defining one point in our circuit, that we use for all ...

View answer
Running Arduino mega on 5V power supply
11 votes

The 6-12V range applies only to the onboard voltage regulator(if you provide power via Vin or the barrel jack). The Arduino itself runs on 5V and the regulator needs a bit headroom above that to do ...

View answer
Delay() and millis() functions don't work in cpp external files
Accepted answer
10 votes

The Arduino framework does some initializing for you before going into setup() and loop(), for example configuring Timer0 correctly for millis(), delay() and siblings. This is done in the main() ...

View answer
Why do we add delay when using ultrasonic sensors?
9 votes

We need to provide the HC-SR04 with a fitting trigger signal. When you read the datasheet of the HC-SR04 you will see that it needs a 10us trigger pulse. The first delay of 2us is to make sure we are ...

View answer
Why are the pin numbers of the diagrams and of the code different?
9 votes

Every chip datasheet (and also the Arduino boards) uses 2 different ways to refer to the pins: Counting the physical pins in the order as they appear on the chosen package of the chip Referring to ...

View answer
How does an LED in an LED-strip like WS2811 know when it should be on or off
Accepted answer
8 votes

The WS2811 is the driver chip, that is embedded into the strip. In principle it is some kind of shift register, that outputs PWM values, and on the strip they are daisy-chained (data output of one is ...

View answer
Controlling a 5V fan and ultrasonic fogger with an arduino - do I need an external power supply?
Accepted answer
7 votes

About the ultrasonic fogger: The product description is misleading. This is a pure transducer. That means it does not generate its own ultrasonic frequency and is thus not DC. You need to provide an ...

View answer
Multiple Wire.write() not working for Arduino Nano I2C
7 votes

Important information: Wire.write() does NOT send anything over the I2C lines. It just puts the data into the libraries internal buffer. The actual transmission is then done by Wire.endTransmission(). ...

View answer
How can I read the data stored in EEPROM although is powered OFF based on the simple code I wrote?
Accepted answer
7 votes

increase is a global variable and will implicitly initialized with the value zero. Then you are reading the EEPROM data into the variable storagedata in setup(). And then in loop() you are increasing ...

View answer
Wire.h library works on Uno but won't compile for ATtiny85
Accepted answer
7 votes

You get this error, because the ATTiny85 doesn't have full I2C hardware. It only as an USI (Universal Serial Interface). This can be utilized to do the rest of the I2C protocol via software. There are ...

View answer
Whats common practice when using more components than there are pins?
6 votes

Basically there are 4 ways to go if you run out of pins: Change to a microcontroller board with more pins Arrange the parts in a smart way to save pins (like if you have many buttons or LEDs you ...

View answer
Why no brackets after Interrupt routine inside attachInterrupt
Accepted answer
6 votes

It is right, that you are putting brackets after the function name if you are calling it. But with attachInterrupt() you just want to give it the information, which function to call in case of an ...

View answer
How to implement Arduino NANO as a RS-232 to USB adapter (Or do I need a Arduino Mega?) For 3D printer comms
6 votes

Its not as easy as you think. An Arduino will not be enough for connecting the USB of the 3D printer. The USB protocol is strictly divided into slaves and masters. A USB(us) has exactly one master, ...

View answer
Using Arduino as a standalone compiler
Accepted answer
6 votes

First of all: The Arduino IDE brings its own GCC compiler. It is a version, that can compile for the AVR platform (don't know, if the standard version is capable of that). When you activate verbose ...

View answer
Connecting an arbitrary number of pins to pin holes without soldering?
Accepted answer
6 votes

As you already have seen, there are not many options to contact such boards without soldering, because they are meant to be soldered. Those hammer headers are an option. When you find a seller for ...

View answer
Arduino Micro 5V Vin and 3v3 pins
Accepted answer
6 votes

Vin is a power INPUT. It is connected to the input of the voltage regulator, which enables you to power the Arduino with voltages between 6V and 12V, while the Arduino itself is running on 5V. The 5V ...

View answer
Is it possible to measure analog output?
Accepted answer
6 votes

First: Why would you need to measure the PWM value. You already know it; it's saved in the val variable. Why not just use this variable for later use in code? Second: Doing the analogRead on the same ...

View answer
Arduino Uno freezes for unknown reason during code execution
Accepted answer
5 votes

The program most likely hangs at Wire.endTransmission();, because that's where the actual I2C communication happens. Wire.write() does nothing but placing the data into the internal buffer of the Wire ...

View answer
Arduino UNO voltage supply reduces when I add more sensors
5 votes

You are overloading the Arduinos voltage regulator. The Arduino uses a linear voltage regulator, which dissipates the excess voltages as heat.The higher the provided voltage, the lesser current you ...

View answer
What is the maximum frequency input signal that I can accurately track on a GPIO pin?
Accepted answer
5 votes

As Majenko wrote, when you only rely on software to measure the frequency on a IO pin, it will always be rather slow. And it also depends on the code, that you use. Functions like digitalRead() are ...

View answer
How do I code delay inside a ISR?
5 votes

An ISR should be kept as short as possible, since while it runs, no other interrupts can be handled (including the one powering the delay() function. Thus you cannot delay that easy inside an ISR and ...

View answer
Difficulties programming Arduino uno for 24 hour cycle
5 votes

On the Uno unsigned int is a 16 bit number. That means, that it can hold values between (and including) 0 and 65535. If you try to write a bigger value to this variable, it will cut of the higher bits,...

View answer
I2C communication in Arduino
Accepted answer
4 votes

All the actual I2C communication is done in Wire.endTransmission(). Before that nothing is done on the I2C lines. Wire.beginTransaction() only initializes the libraries buffer and saves the slave ...

View answer
Random Blink with millis()
Accepted answer
4 votes

Your problem descriptions is a bit unclear, though I think I see your problem. On every loop() iteration you call randomBlink(), which generates a new random delay value and then calls ledBlink(), ...

View answer
LCD displays more digits than serial monitor
4 votes

The additional "6" seems to come from one of the first values. Maybe the first value printed is just a rogue value and all the following values are correct. The point is that this rogue ...

View answer
How to send multiple data over serial in one byte?
Accepted answer
4 votes

You should learn how to use bitwise operators. These are needed to do what you want. We can save the state of each switch in one bit each. For this we first define our global variable that will hold ...

View answer
MPU6050 Arduino Jeff Rowberg library interrupt Issue
4 votes

The functions mpu.dmpGetCurrentFIFOPacket(fifoBuffer), etc, are using I2C for getting the data. The I2C interface on the Uno and Mega (which you tagged your question with) is implemented in hardware ...

View answer
Global array doesn't get assigned the space it would take up in memory
Accepted answer
4 votes

There is no problem here. Only the compiler is a bit smarter than you anticipated. It sees, that you are not using arr anywhere, so it just optimizes it out. There are two ways to prevent that, if you ...

View answer
1
2 3 4 5
20