Hot answers tagged

11 votes
Accepted

Is Arduino IDE enough to program with C or C++?

In terms of the core language features, there's virtually no difference. In the background, the Arduino IDE and Atmel/AVR Studio both use GCC to compile the code. GCC is an excellent toolset which ...
user avatar
9 votes
Accepted

Why are Arduino timer registers not 0?

The Arduino core does things at startup. One of those things is to configure the timers ready for PWM operation. Here's the relevant bits from init() in wiring.c: // set timer 1 prescale factor ...
user avatar
  • 103k
9 votes
Accepted

Can I program a factory fresh Atmega328P through UART pins without burning a bootloader?

No, the ATmega's ISP does not operate over the UART pins but only the ISP pins. To program it via a UART, you need to first load a bootloader, unless your chip was pre-programmed by the vendor, ...
user avatar
8 votes
Accepted

Arduino compatible's serial port not showing Mac OSX

From the OSX System Report we learn that your board is based on an SiLabs CP2102 converter (or workalike), but according to your question you installed the drivers for an entirely different product ...
user avatar
8 votes
Accepted

Why can't the Atmel ATtiny family delay over a minute?

This is absolutely nothing to do with "why can't the atmel attiny family delay over a minute?". It is all to do with the way that C++ works. See my page about Integer arithmetic and overflow. To ...
user avatar
  • 35.3k
8 votes
Accepted

How does the microcontroller know which clock to use?

Burning the bootloader via the Arduino IDE also sets the fuse bits according to its configuration files.
user avatar
7 votes
Accepted

How can I make pinMode calls faster?

First, figure out which port and pin you're using. Then, manipulate them. DDRC &= ~_BV(PC5); PORTC |= _BV(PC5); ... DDRF &= ~_BV(PF5); PORTF |= _BV(PF5); ... DDRF &= ~_BV(PF0); PORTF |...
user avatar
7 votes
Accepted

How are errors (not related to syntax) managed in arduino and in the AVR architecture in general?

The simple answer is: they are not handled at all. According to the C and C++ standards, what you are invoking is called undefined behavior, meaning anything can happen. In practical terms, it means ...
user avatar
  • 36.8k
6 votes
Accepted

Cannot compile C++11 code via Makefile

As I turns out, the avr-gcc (GCC) 4.9.1 goodies weren't being used at all! The arduino package was using a decrepit version of gcc, prakhar@sim74stic ~ $ /usr/share/arduino/hardware/tools/avr/bin/avr-...
user avatar
  • 358
6 votes

I2C 2 way communication between Arduino Uno and Arduino Mega

To join the bus as a master you cannot supply a 7-Bit slave address so your code has two slaves. Below you will find 2 sketches that successfully sends data to a slave. I would suggest you start ...
user avatar
  • 161
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-...
user avatar
  • 103k
6 votes

How to use printf with Arduino's serial ports without an intermediary buffer?

Sure - here's a Hello, World program that uses printf(). Everything that mentions "uart" is what connects printf() to your output stream. uart_putchar() does the actual outputting to ... someplace. ...
user avatar
  • 14.5k
6 votes

What does an arduino sketch translate to before compilation?

The Arduino core libraries (which are nothing more than a bunch of C/C++ files - there is no such thing as the "Arduino" programming language), are compiled along with your source code. These files ...
user avatar
6 votes

My Digispark board won't show up in Ports tab in Arduino IDE (OSX)

I don't think it is supposed to. The Digispark briefly connects in "bootloader" mode, which you spotted as "Vendor-Specific Device:". Then after 5 seconds it runs the loaded sketch. If your sketch ...
user avatar
  • 35.3k
6 votes

How can a function/method determine if a const array passed in is PROGMEM (flash) or not (RAM)?

I am afraid there is no good solution to this problem. One option I do like is to use the __flash qualifier instead of PROGMEM: const uint8_t ram_array[] = { 1, 2, 3, 4 }; __flash const uint8_t ...
user avatar
  • 36.8k
6 votes
Accepted

Problem with programming digispark ATtiny85 board with Arduino IDE

i=i++; //increment by one The result of the above statement is not defined. That is, it is not necessarily "i + 1". See: http://en.wikipedia.org/wiki/...
user avatar
  • 35.3k
5 votes
Accepted

How are Arduino's OSH if Atmel AVR is proprietary?

The components are necessarily going to be proprietary. There is no feasible way around this. If you wanted to design a new open source microcontroller from scratch with no proprietary components, ...
user avatar
5 votes
Accepted

I bought USB > FT232RL, can I use it to program a bootloader onto an Arduino?

In fact, you can, but you are unlikely to enjoy it as it will be fairly slow. While this module is intended for serial communications - which the ATmega won't support until it has a bootloader on it -...
user avatar
5 votes

Arduino compatible's serial port not showing Mac OSX

just to add to the list - some cheaper boards use CH340 chipset here is a blogpost on how to install the drivers on OSX http://javacolors.blogspot.ie/2014/08/dccduino-usb-drivers-ch340-ch341-chipset....
user avatar
  • 151
5 votes
Accepted

Is it possible to program an Attiny85 with a USB-to-TTL converter?

Yes, it is possible. Note that the FTDI chip (assuming that is what you have) can be accessed as either Virtual Com Port VCP or D2XX. Where VCP is the traditional method of using them as Serial Ports ...
user avatar
  • 2,443
5 votes

New to Arduino: Should I learn C, C++ or both (C & C++)?

The basic syntax of C and C++ is very similar, to the point that C code can typically be compiled directly as C++. You'll also find C standard functions (such as printf and malloc) can be used from C++...
user avatar
5 votes
Accepted

AVR timer overflow interrupt not working

You are misunderstanding what an overflow interrupt is. That is called when the timer overflows (ie. it reaches TOP which in the case of an 8-bit timer is 255). Since you are counting to 124 that will ...
user avatar
  • 35.3k
5 votes

How to convert Arduino example sketch to a complete c++ project?

Basically *.ino is *.cpp without headers. So you can rename it to *.cpp, If you have any functions which are used before they have been defined, provide declarations for each function before its ...
user avatar
  • 1,300
5 votes
Accepted

Why we can wake Arduino Uno from sleep using only pin 2?

It's not just Pin 2 that can wake from sleep. Depending on which sleep mode you are in different interrupts (both internal and external) can wake the chip up. The datasheet contains this helpful ...
user avatar
  • 103k
5 votes
Accepted

What's in an Arduino?

You did not specify what Arduino board you are talking about. It would have been useful to tag the question with the appropriate board name. In the following, I assume you want something similar to an ...
user avatar
  • 36.8k
5 votes

Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?

Yes you can. This Arduino IDE add on lets you make calls to code store in the bootload of memory so you can make changes to the flash memory. https://majek.sh/en/writing-to-internal-flash-on-arduino/ ...
user avatar
  • 2,340
5 votes
Accepted

Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?

The answer is "yes, you can use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage, very similar to an STM32 microcontroller." One of these days I'm going to write an Arduino ...
user avatar
4 votes
Accepted

error: ‘sleep’ was not declared in this scope

"sleep()" is not a function on arduino. The sleep.h file contains functions for the hardware sleep functionality used to reduce power consumption when processing isn't necessary. "delay()" is the ...
user avatar
  • 4,309

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