jfpoilpret
  • Member for 7 years, 10 months
  • Last seen more than 1 year ago
12 answers
63 votes
394k views
How do I split an incoming string?
Accepted answer
87 votes

Contrarily to other answers, I'd rather stay away from String for the following reasons: dynamic memory usage (that may quickly lead to heap fragmentation and memory exhaustion) quite slow due to ...

View answer
5 answers
18 votes
174k views
How can I declare an array of variable size (Globally)
Accepted answer
27 votes

Your question has 2 parts actually. 1/ How can I declare the constant size of an array outside the array? You can either use a macro #define ARRAY_SIZE 10 ... int myArray[ARRAY_SIZE]; or use a ...

View answer
7 answers
88 votes
48k views
How to organize my Arduino projects' structure for easy source control?
Accepted answer
20 votes

Here is the way I finally decided to follow for my projects. Arduino-CMake The first important decision I made was the choice of a build tool that could work for my environment (Windows) but was not ...

View answer
13 answers
58 votes
67k views
Is there a way to have more than 14 Output pins on arduino?
19 votes

If you want to drive LEDs, then you can also use a MAX7219 that can drive 64 LEDs, without extra circuitry (no need for transistor to amplify signal). Driving a MAX7219 requires only 3 output pins on ...

View answer
8 answers
58 votes
97k views
Is using malloc() and free() a really bad idea on Arduino?
18 votes

Typically, when writing Arduino sketches, you will avoid dynamic allocation (be it with malloc or new for C++ instances), people rather use global -or static- variables, or local (stack) variables. ...

View answer
4 answers
30 votes
79k views
What can I do if I run out of Flash memory or SRAM?
17 votes

In addition to what others have said (on which I fully agree), I would advise to read this adafruit article about memory; it's well written, explains a lot of things about memory and provide hints on ...

View answer
5 answers
19 votes
7k views
How much can I recurse? How much can I recurse? How much ca!@#QFSD@$RFW
Accepted answer
15 votes

If you really want to recurse (and as @jippie said it is a bad idea; subliminal message: don't do it) and want to know how much you can recurse, then you will have to perform some calculation and ...

View answer
4 answers
19 votes
8k views
How can higher current devices (motors, solenoids, lights, etc.) be controlled by an Arduino?
Accepted answer
13 votes

To drive such high currents, you may have to cascade several transistors (you can also use a Darlington transistor). There are arrays of Darlingtons mounted in a chip (e.g. the ULN2803A has 8 ...

View answer
2 answers
8 votes
20k views
Why does an Arduino UNO need two GND ports?
Accepted answer
11 votes

In electronics circuits, a major point in connecting two circuits and make them "talk" together is to ensure, at the minimum, that they have a common reference of voltage (typically called GND and ...

View answer
4 answers
13 votes
34k views
What's the deal with Uno's pin 13 LED?
Accepted answer
11 votes

The LED on pin 13 is used by the optiboot loader (the one used on UNO): at Arduino boot time (the LED blinks a few times) when uploading a sketch to Arduino I haven't checked other bootloaders, they ...

View answer
5 answers
9 votes
12k views
How can an Arduino output a specific (i.e. 56 kHz) carrier frequency?
Accepted answer
10 votes

It is indeed possible to generate a 56 kHz signal with an Arduino timer. A timer actually can be seen as a special register, in the MCU, that holds a value (starting at 0) that gets incremented at a ...

View answer
2 answers
4 votes
3k views
What's taking up so much RAM in an almost empty sketch?
10 votes

First off, a sketch that uses Serial cannot really be considered an empty sketch as Serial drags along a lot of function definitions, at least one Serial class instance (more on Arduino Mega, for ...

View answer
3 answers
12 votes
17k views
Can tx and rx pins on the uno be used like regular digital pins?
Accepted answer
10 votes

Yes you can perfectly use these 2 pins as long as your program does not use Serial. EDIT: Serial data over USB goes through copper traces connected to the rx and tx pins, connecting them to the USB ...

View answer
14 answers
31 votes
54k views
Most compact method of powering Arduino from wall socket
10 votes

Nowadays, most smartphones come with a charger that is linked to the USB plug of the phone. The charger for my HTC says: 5V, 1A, I guess this voltage must be regulated (but I haven't checked it has ...

View answer
5 answers
19 votes
9k views
I'm using too much RAM. How can this be measured?
10 votes

The main issues you can have with memory usage at runtime are: no available memory in the heap for dynamic allocations (malloc or new) no room left on the stack when calling a function Both are ...

View answer
5 answers
4 votes
11k views
SRF04 Ultrasonic sensor - inaccurate readings
Accepted answer
9 votes

Just don't use that library, it seems poorly designed. Here is how the distance for roundtrip is calculated (code excerpts): long sum = 0; for (int i=0;i<_average;i++) { digitalWrite(_trigPin,...

View answer
2 answers
11 votes
21k views
3.3V, 5V and 9V pins on Arduino
9 votes

The link you provide looks rather old and I don't think it applies to UNO Revision 3 as it has more pins than on the diagram you show. I suggest you rather take a look at this Arduino UNO link which ...

View answer
9 answers
72 votes
153k views
How can I create multiple running threads?
9 votes

As per the description of your requirements: one thread waiting for an external device one thread blinking a LED It seems you could use one Arduino interrupt for the first "thread" (I would rather ...

View answer
3 answers
2 votes
406 views
for loop running infinitely
8 votes

After a chat with OP, it turned out this was a more complex issue, probably a memory overrun. This cannot be seen in this small snippet, but the whole program is using memory extensively (global ...

View answer
2 answers
7 votes
14k views
Difference between SoftwareSerial and Serial
Accepted answer
7 votes

All Atmel MCU, on which Arduino models are based, include special hardware for serial communication; this part of the MCU is called USART (stands for Universal Synchronous/Asynchronous Receiver/...

View answer
2 answers
3 votes
11k views
Why can't this C++ program read my arduino's Serial.write()?
Accepted answer
7 votes

The problem is in your C++ program at the other end of the line (not the Arduino side): char* c = ""; int len = strlen(c); while(c == "") { serial.ReadData(c, len); } Here, len is zero because ...

View answer
1 answers
7 votes
3k views
Arduino sizeof Servo array objects is.. wrong?
Accepted answer
7 votes

What you describe seems to be a common issue that many C or C++ developers can get (or have got) with sizeof. Take a look at the following code: char a[3]; int size(char b[]) { return sizeof b; } ...

View answer
1 answers
1 votes
228 views
Should a delay be expected to cause deadlock?
Accepted answer
7 votes

You don't seem to use standard Arduino stuff since you defined your own main() which is normally avoided when programming Arduino. If you take a look at Arduino provided main() (in hardware/cores/...

View answer
1 answers
5 votes
769 views
Is my ATmega broken, and would replacing it with another break that one, too?
Accepted answer
7 votes

Besides breaking a pin while removing the IC from its socket, or static electricity during manipulation, I don't see what could fry the ATmega. However, it is possible that the R2 ATmega has a ...

View answer
2 answers
1 votes
123 views
4 bit to Decimal Converter IC
Accepted answer
6 votes

You can use one (or more, daisy-chained) shift register for that. It will normally take you 3 pins and provide 8 outputs, or 8n where n is the number of chained shift registers still using only 3 ...

View answer
2 answers
6 votes
52k views
Servo won't stop rotating
Accepted answer
6 votes

I suppose you are using a continuous servo otherwise you won't be able to make it turn 90° more than twice (a normal servo has a varying angle of only 180°). Now if you are using a continuous servo, ...

View answer
2 answers
17 votes
32k views
When should I use a transistor, mosfet, and when should I use a relay?
6 votes

Big differences between relays and transistors are: relays are all-or-nothing (like switches) whereas transistors can transmit more or less current through the collector based on the current present ...

View answer
3 answers
2 votes
2k views
Arduino Interrupt example not working
Accepted answer
5 votes

I think you misunderstood this example: it is not expected to automatically blink! The LED is suposed to change state at every change of level on pin 2. This supposes that you wired something (e.g. a ...

View answer
1 answers
2 votes
6k views
pulseIn() function not working
Accepted answer
5 votes

pulseIn() returns an unsigned long (32 bits) not an int (16 bits), so you may have some truncation occurring in your program leading to a 0 value. Hence you should modify your program as follows: ...

View answer
1 answers
2 votes
2k views
Arduino: Hardware SPI hangs, bit-bang does not
Accepted answer
5 votes

According to ATmega32u4 datasheet, section 17.2.1 (SPI / SS Pin Functionality / Master Mode: If SS is configured as an input, it must be held high to ensure Master SPI operation. In your circuit, ...

View answer
1
2 3 4 5