139 votes
Accepted

Have I bricked my Arduino Uno? Problems with uploading to board

It probably isn't bricked I've got quite a few Arduinos, and over the last few years have only ever "bricked" one, and I think that was by zapping it with static electricity. Unfortunately that ...
  • 36k
36 votes
Accepted

How do interrupts work on the Arduino Uno and similar boards?

TL;DR : When writing an Interrupt Service Routine (ISR): Keep it short Don't use delay () Don't do serial prints Make variables shared with the main code volatile Variables shared with main code may ...
  • 36k
17 votes
Accepted

What to do with Arduino floating pins?

The simplest thing to do is set them to INPUT_PULLUP. If you want a purely hardware solution then you could connect them to GND through some resistors (10kΩ or whatever you have in that kind of order ...
  • 104k
16 votes

Have I bricked my Arduino Uno? Problems with uploading to board

At least - as I assume you upload your sketch via avrdude - please give more information about the upload failure (e.g. output of sketch uploader) so people here can help you better. Additionally to ...
  • 261
16 votes
Accepted

What is the purpose of the I/O pin capacitor on the AVR microcontroller?

To make explicit the implicit parasitic capacitance on the pin.
  • 2,750
15 votes
Accepted

very lightweight low power microcontroller with memory?

I made up a small torch locator which used an ATtiny85 powered from a button-cell (CR2032). It looks like this: Other side: That currently weighs 5.9g. The battery-holder weighs 1.6g so you could ...
  • 36k
15 votes

Why connect a diode between the reset pin of Arduino and 555 timer?

It's called a "Wired Or" arrangement. The Arduino's RESET pin has a pullup resistor in it (10KΩ). That keeps the RESET pin normally HIGH. To invoke a reset that pin needs pulling low, and that is ...
  • 104k
14 votes
Accepted

ATMEGA328P-U vs ATMEGA328-PU

The main difference is the bit before the -. That is, the 328 vs the 328P. The "P" there denotes "Picopower" which allows the chip to run at very low power consumptions. Basically the P version is ...
  • 104k
12 votes
Accepted

Put ATmega328 in very deep sleep and listen to serial?

A board we make does this. The RX pin is wired to INT0 INT0 pin set to input or input pullup depending on how the RX line is driven On sleep, INT0 low level interrupt is enabled //Clear software ...
  • 2,906
12 votes
Accepted

Can we burn Arduino bootloader into any microcontroller chip?

The answer needs to have multiple parts: Yes, in principle you can create a bootloader for any microcontroller, which acts like the Arduino's. Please be aware that there are different bootloaders, ...
  • 1,359
10 votes
Accepted

Programming Chinese Arduinos

It's because these are unprogrammed chips, meaning they haven't had a bootloader programmed into them yet. Here is a tutorial for using your Arduino board to program a bootloader into them (there are ...
  • 14.8k
9 votes

Program an ATMega328P and use it without Arduino board

Yes you can use ATMega328P without arduino board. I always use the IC without arduino. There are two ways of doing it. You can use arduino board with the IC. Program the IC and then take it out and ...
  • 293
9 votes
Accepted

Arduino 16 MHz with only 3.3V?

Officially, no. Practically, often but not always. If I follow the datasheet to the the letter, this configuration should not work. BUT... After some test, it did work. The data sheet does not ...
9 votes

Does the reset button work when not powered?

The reset on an Arduino does not erase anything. It merely restarts execution of an already uploaded program. Also the AVR needs to be powered on for it to realize whether it has been reset. Every ...
9 votes
Accepted

Is there a way to disable modules like ADC without a sleep mode?

Certainly there is. // disable ADC ADCSRA = 0; You can disable lots of internal modules like this: power_all_disable(); // turn off all modules See my page about power saving. Majenko ...
  • 36k
9 votes
Accepted

Powering Atmega328p from 4.5V

From the ATmega328P datasheet: Within the range 2.7 V – 4.5 V, the maximum frequency is a linear function of Vcc. From this graph, you can compute the minimum value of Vcc required to run the ...
  • 39.6k
8 votes

Put ATmega328 in very deep sleep and listen to serial?

The code below achieves what you are asking: #include <avr/sleep.h> #include <avr/power.h> const byte AWAKE_LED = 8; const byte GREEN_LED = 9; const unsigned long WAIT_TIME = 5000; ISR (...
  • 36k
8 votes

very lightweight low power microcontroller with memory?

I would personnaly suggest an ATtiny 45/85. It is pretty much a small AVR with 5 GPIOs. You can program it with the Arduino IDE and use the Arduino as ISP. If you can design you own custom PCB, a SMD ...
  • 2,883
8 votes
Accepted

Sending serial data in an interrupt

You cannot use Serial inside an interrupt. Transmitting Serial relies on interrupts being available, and from inside an interrupt they aren't. All Serial communication must be done from loop(). So ...
  • 104k
8 votes

Run code once after programming

This is a X->Y problem. Here is a solution for X: Bit 3 of high fuse of the ATmega328p controls if EEPROM memory is preserved through the chip erase. You can change the high fuse setting in boards....
  • 17.1k
7 votes
Accepted

What are the implications of running an ATmega328P at 8 MHz and 3.3 V with the Arduino system?

The formula seems to be volt*5.9-6.6=mhz (valid between 1.8v and 4.5v), so at 3.3v, this would give 12.8mhz. Be aware that, if you are running at 12.8mhz, ANY drop below 3.3v MAY cause problems (and ...
7 votes

Program an ATMega328P and use it without Arduino board

You can remove an ATMEGA from an Arduino and use it in your own board, however when used on a typical Arduino board the chip will be fused for an external crystal as a clock source, rather than the (...
7 votes
Accepted

Two function Reset button - long/short press

It can be done with one button, one resistor, one capacitor and one GPIO pin (in addition to the RESET pin): simulate this circuit – Schematic created using CircuitLab Pressing the button ...
  • 104k
7 votes
Accepted

Why doesn't millis() use 1 µsec or 1 msec interrupt?

One microsecond is only 16 CPU cycles. The CPU needs 4 cycles to prepare itself for servicing the interrupt (save the program counter, load the interrupt vector and clear the I bit in SREG). The ...
  • 39.6k
7 votes

ATMEGA328P-U vs ATMEGA328-PU

There are three die types: 328 328P 328PB all have different signature bytes which may or may not impact loading code into them. Generally tho the programming software needs to know which part ...
  • 2,384
7 votes
Accepted

How to deep sleep ATtiny/ATmega (to run for years with batteries) but still detect a button press?

ATTINY's are designed to easily do this since they can wake from power down sleep mode by a pin change... Basically you want to... Connect a normally-open push button between an IO pin and ground....
  • 1,515
6 votes

Should I use an Arduino or not?

Short answer: Yes. After all, Arduinos are made by starting with an ATMega (or other AVR) IC. Longer answer: People - including myself - routinely build with a bare ATMega328p (or other MCU), ...
  • 14.8k
6 votes

Lowest power possible in Arduino

The issues regarding efficiency of power are: The CPU speed The Voltage The Power Regulator (not supply) The Peripherals Address each one of these and don't over look any of them. Or any sub ...
  • 2,453
6 votes
Accepted

Basic makefile for avr-gcc

It's no different to working with Make and any other form of GCC. Just set your CC variable and CFLAGS variable accordingly and work as per normal. For instance, I just knocked this one up: CC=avr-...
  • 104k

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