As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

76 votes

Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding

Know this is old but I ran onto it during my search for Nano(V3)'s not uploading so thought might help someone else. Problem is the bootloader - Arduino IDE BUT I Found an easy solution (right under ...
Goofy Brained's user avatar
9 votes

What's taking up so much RAM in an almost empty sketch?

I investigated this at some length a while back. On this page about putting constant data into program memory I obsessively tracked down every last byte of memory used in a small sketch. This was the ...
Nick Gammon's user avatar
  • 36.4k
8 votes
Accepted

How to read code from Arduino Uno to Arduino IDE?

Can we read and get C codes from compiled codes from Arduino hardwares? While it is possible, even trivial, to disassemble machine code, it is very difficult to convert the assembly code into a ...
Ignacio Vazquez-Abrams's user avatar
8 votes

Loading local libraries

Okay, here is how it works, and I checked it to make sure. Sure you can use hard paths, but every programmer hates using hard paths. They are not portable at all, and they lock your program in place. ...
Sean Walton's user avatar
8 votes
Accepted

ino.hex vs ino.with_bootloader.hex

If flashing with AVR In System Programing (ISP) the bootloader is not needed. Only the flashing over Serial needs a bootloader. The ISP erases the flash including the bootloader. To be able to use ...
Juraj's user avatar
  • 17.2k
7 votes

Double ## in macros

## is the concatenation operator in macros. It joins two macros or pieces of text together when expanded. #define _SET_INPUT(IO) do {DIO ## IO ## _DDR &= ~MASK(DIO ## IO ## _PIN); } while (0) ...
Majenko's user avatar
  • 104k
7 votes
Accepted

"stray '/302' in program error" when compiling

0302 is 0xc2. Somewhere in your source you have one or more non-breaking spaces (0xa0) encoded in UTF-8 (0xc2 0xa0). Use od or a similar tool to find them, and then replace them with normal spaces. ...
Ignacio Vazquez-Abrams's user avatar
7 votes
Accepted

Using Arduino as a standalone compiler

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 ...
chrisl's user avatar
  • 15.3k
6 votes

Is there any way to download a sketch from an Arduino?

Unless your objective is to simply copy the identical code to another device, the simple answer is: no As has been pointed out in other answers, you can turn the hex code on the device back into ...
Nick Gammon's user avatar
  • 36.4k
6 votes

Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding

I was having the same problem and got the same error message. Turns out these boards don't come with a bootloader preinstalled. If you have some jumper wires and another working arduino you can use ...
electriccello's user avatar
6 votes

How to generate true random numbers over Arduino Uno without any external hardware?

The standard (but not very good) solution is to seed the random number generator from an analogRead() on an unconnected pin. For better options, see this answer to a related question.
Edgar Bonet's user avatar
  • 40.2k
6 votes
Accepted

What exactly does the Arduino preprocessor do?

It does four things, basically: It adds #include <Arduino.h> to the top of your file, which gives you access to all the classes, functions and defined variables/macros of the API. It joins ...
Majenko's user avatar
  • 104k
6 votes

What is wrong with my code? RGB potentiometer

Equality comparison in C and C++ is expressed by == operator. ==, not =. This if (wavecolor = 0) { actually assigns zero to your wavecolor variable, thus destroying the value you just read. The ...
AnT stands with Russia's user avatar
5 votes
Accepted

questions about sketch

Lean the proper C syntax. This is completely wrong: void gf() int a = f;//test the conditions of f and store in new variable int a { And this is just as wrong for the same reasons: void ei() int k =...
Majenko's user avatar
  • 104k
5 votes

What programming practices should be adopted while coding sketches for Arduino?

Paul covered the most important points. This answer is intended to be a complement to his. First, you should keep in mind the general rules, which are more important than the more specific ones. The ...
Edgar Bonet's user avatar
  • 40.2k
4 votes

How to avoid report of unsuitable sketch names?

That message is actually a hang-over from when the IDE was Processing. The name of a file had to match the name of the Java class within that file, and there are strict rules about what can be in a ...
Majenko's user avatar
  • 104k
4 votes
Accepted

Integrating Shift Registers into 7 Segment LED Circuit

I have done exactly this, to great effect. int clockPin = 4; int dataPin = 2; int oePin = 3; // Here are the digits from 0 to 9, as bitmaps. // You will need to work out which segments are which,...
AMADANON Inc.'s user avatar
4 votes

Programming arduino with Objective-C

Simple version: No, you cannot program Arduino using Objective-C. Long version: The Arduino IDE uses avr-gcc as it's compiler, and avr-gcc is a C/C++ compiler, not an Object-C compiler. The Arduino ...
Bad Wolf's user avatar
  • 146
4 votes

Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding

I recently had the same issue with 3 Nano boards I just purchased from Amazon. I can confirm that the suggested fix (changing to "old bootloader") solved my problem. I think the main problem is the ...
Curtg's user avatar
  • 57
4 votes

Loading local libraries

I recently tested this local library structure. It works with: #include "libs/MyNewLib/MyNewLib.h" The Arduino IDE 1.6.7 build pre-processing will even pick up the source code for the library. ...
Mikael Patel's user avatar
  • 7,929
4 votes
Accepted

What is better: one sprintf() or multiple strcat() and itoa()?

Why do you feel you need to use either method? Neither are needed. Just print the individual parts: Serial.print('X'); Serial.print(first); Serial.print('Y'); Serial.print(second); Serial.println('T')...
Majenko's user avatar
  • 104k
4 votes

"stray '/302' in program error" when compiling

One cause of the /(302) error is copy and paste code from a word processor. You have ASCII codes copied that add spaces, etc to your code. Go through each identified line and remove any extra spaces ...
RogerR2's user avatar
  • 51
4 votes
Accepted

How to execute commands on Arduino (via PC) without touching the current sketch?

The simple thing would be for your sketch to read from the serial port continuously. If it finds something it stores it and when a newline arrives it sees if that happens to be a password known only ...
Nick Gammon's user avatar
  • 36.4k
4 votes
Accepted

Code is not working (Matrix keypad)

Cited comment: Check pin modes. Should be INPUT_PULLUP and OUTPUT. Also, consider debouncing. – Mikael Patel Please, try: const char keymap[4][4]={ {'1','2','3','A'}, {'4','5','6','B'}, {'...
AltAir's user avatar
  • 542
4 votes

What exactly does the Arduino preprocessor do?

See my answer: How the IDE organizes things I'm not sure if link-only answers which refer to a Stack Exchange link are OK. In case they are not, here is the first part of that answer: This is how ...
Nick Gammon's user avatar
  • 36.4k
4 votes

The sketch burned two H Bridges, need help to find out how to modify

As you wrote in comment you use this H bridge: https://www.ebay.com/itm/60A-DC-Motor-Driver-Module-High-Power-motor-Speed-Control-Dual-Channel-H-bridge/122479397950 The description how to use it is ...
Filip Franik's user avatar
  • 1,272
4 votes

Branchless programing on arduino?

There is no cache, so you don't need to worry about that. All instructions are fetched direct from flash and executed straight away. There is, though, a 2-stage pipeline. That means that in one clock ...
Majenko's user avatar
  • 104k
4 votes

Can Arduino Sketch be used for production

There's a lot of controversy on this issue, but if it works for your needs, absolutely do it! Basically, there are 2 questions you have to answer: Should I use actual Arduino boards in production? ...
Gabriel Staples's user avatar
3 votes

DC motor makes noise but does not rotate

For the benefit of anyone reading Jeremy Blum's Exploring Arduino book who is having the same issue- he has labelled the transistor wrong in the book so the collector and emitter are back to front. ...
Anon's user avatar
  • 31
3 votes

Is there any way to download a sketch from an Arduino?

Download: avrdude \ -c <programmer type> \ -P <connection port> \ -b <override RS-232 baudrate> \ -p <partno, AVR device> \ -U <memtype>:r:file_name[:...
Doc's user avatar
  • 31

Only top scored, non community-wiki answers of a minimum length are eligible