Hot answers tagged

69 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 ...
user avatar
12 votes

Asynchronous function calls in Arduino sketch

Yes and no. You're kinda vague on what you want to do. I've made this into a few different sections (mainly focused on reading sensor data... it applies to everything but that's the context I'm using):...
user avatar
10 votes

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

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 ...
user avatar
  • 8,829
9 votes
Accepted

Is it possible to run a binary from EEPROM?

Short answer: No; From the atmega328's data sheet (though it applies to all AVR's): AVR uses a Harvard architecture – with separate memories and buses for program and data. Instructions in the ...
user avatar
  • 4,309
9 votes
Accepted

ATtiny85 minimum setup to blink led

This schematic shows a complete connection of a blinking led. Red cable = +5V (pin 8) White cable = Ground (pin 4) Resistor = 1 end at pin 5 (IO 0) and the other in the LED anode (+) Led anode (+) in ...
user avatar
  • 269
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 ...
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 ...
user avatar
  • 16.2k
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 ...
user avatar
  • 35.2k
7 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. ...
user avatar
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 ...
user avatar
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) ...
user avatar
  • 102k
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. ...
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 ...
user avatar
  • 13.8k
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 ...
user avatar
  • 35.2k
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 ...
user avatar
  • 61
6 votes

ATtiny85 minimum setup to blink led

Ignacio Vazquez-Abrams has already outlined the schematics. There must be a C program compiled and uploaded to it, just like an Arduino board would have. There are however some differences ...
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.
user avatar
  • 36.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 ...
user avatar
  • 102k
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 ...
user avatar
5 votes

Is it possible to run a binary from EEPROM?

No. The foundation of a Harvard architecture such as AVR is to only allow code that exists within program space to be executed, and EEPROM is not within program space. It is possible, however, to ...
user avatar
5 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 ...
user avatar
5 votes
Accepted

Many "expected `)' before ';' token" errors

You have two #define statements at the top of your code #define trigPin 3; #define echoPin 2; The way #define works is that it replaces every instance of the name with everything after it on the ...
user avatar
5 votes

ATtiny85 minimum setup to blink led

Here is the absolute minimal schematic required to blink a LED beyond power and decoupling: Refer to "Which resistor to use for this LED" to calculate the appropriate value for R1.
user avatar
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.
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 =...
user avatar
  • 102k
4 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, ...
user avatar
  • 163
4 votes

Wrong data from DS18B20 temperature sensor after long power off

I researched this once when I was getting consistent, exactly 85 degC readings from my sensors. The Maxim DS18b20 data sheet (rev 042208, page 4, in a footnote to Table 1) says: "The power-on ...
user avatar
  • 14.5k
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 ...
user avatar
  • 146
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,...
user avatar
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 ...
user avatar
  • 102k

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