Hot answers tagged

73 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 ...
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. ...
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 ...
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 ...
  • 17.1k
7 votes

How to add hysteresis to threshold values?

Adding hysteresis behavior to your code is not difficult. You just need to store the state you're in and make the thresholds for transitioning into another state dependent on that. You can use an ...
7 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 ...
  • 36k
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) ...
  • 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. ...
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 ...
  • 15.2k
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 ...
  • 36k
6 votes

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

I think there is another way to do this, without extracting the code from the Arduino board. Remenber the date you create the sketch, and look for it in C:\Users\User\AppData\Local\Temp\ (For example ...
  • 61
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 ...
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.
  • 39.7k
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 ...
  • 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 ...
5 votes

What do these operators do?

They are the conditional operator. If the expression before the ? is true then the result is the expression before the :, otherwise it is the expression after.
5 votes

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

Having a similar issue with my Sainsmart Nano. Under Preferences check "Show verbose output during [x] upload, then when uploading, you should get a red trace like this: avrdude: Version 5.11, ...
  • 173
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 =...
  • 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 ...
  • 39.7k
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 ...
  • 57
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 ...
  • 146
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. ...
  • 7,929
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,...
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 ...
  • 104k
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')...
  • 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 ...
  • 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 ...
  • 36k
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'}, {'...
  • 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 ...
  • 36k
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 ...
  • 1,272

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