Hot answers tagged

78 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
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.9k
8 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
  • 105k
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
  • 105k
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
  • 16.2k
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
  • 42.8k
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

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,969
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
  • 105k
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
  • 42.8k
5 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
  • 38.1k
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

"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
  • 38.1k
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

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,292
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
  • 105k
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
3 votes

Can an a Arduino make music or speech without a speaker?

Sound happens because of a disturbance in the air (or other conducting medium). So the short answer is an unqualified "yes." To start making a recognizable "tune" or "voice" you would need to vary the ...
dlu's user avatar
  • 1,651
3 votes

Problem: "stray '#' in program"

From the Instructable you linked: matrix8x8.pde is a program in Processing to build your own displays. You downloaded the Processing code, not the Arduino code. See above that: cube8x8x8.pde ...
Nick Gammon's user avatar
  • 38.1k
3 votes

Include Git tag (or SVN revision) in Arduino sketch?

I struggled with Arduino (ESP32) versioning also. To make it somewhat more practical and less error prone I made some scripts to assist this process. Using these scripts is as easy as adding them to ...
Cellie's user avatar
  • 31
3 votes
Accepted

HUGE deviation in Sharp IR sensor values if other pins are defined in void setup()

Not sure why commenting out those two lines makes a difference. I think we need to see a schematic to resolve this. However... You do not use "pinMode" to setup an analog input! Look at the ...
st2000's user avatar
  • 7,325
3 votes

Why does HC-SR04 return 0s in this sketch

pulseIn() may block up to 1 second (by default), which would happen everytime the HC-SR04 receives no echo, which might be the case if ultrasounds do not get properly reflected on a flat surface or if ...
jfpoilpret's user avatar
  • 9,122
3 votes

How do I convert a program made on Notepad to my Arduino on Proteus

Besides displaying source code and letting you edit it, the IDE uses avr-gcc (and half a dozen other avr- utilities, like avr-objcopy, avr-ar, avr-nm) to compile and link the code and convert it to an ...
James Waldby - jwpat7's user avatar
3 votes

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

Keep in mind that RAM is even less. 32KB is a fair lot of code, since C/C++ is highly efficient. "Don't save **** in RAM." If you need to load images into a display, save the images on an SD card. ...
Paul's user avatar
  • 2,695
3 votes
Accepted

Is there a way to "list" (in BASIC, or "cat" in LINUX) the current sketch loaded in my xxxDUINO?

No. the code burned in an Arduino is compiled not interpreted like Basic. Basically your C language sketch is compiled into AVR assembly language. The resulting hexadecimal is what is burned to the ...
Andre Courchesne's user avatar

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