112
votes
Accepted
How do you use SPI on an Arduino?
Introduction to SPI
The Serial Peripheral Interface Bus (SPI) interface is used for communication between multiple devices over short distances, and at high speed.
Typically there is a single "...
44
votes
Mac OSX Yosemite no serial ports showing for Uno R3
Probably, you have Chinese Uno analog which works on CH340 USB-to-serial chip, so you need to install driver for it.
Steps to fix:
Install the CH340 driver
Run the command in Terminal: sudo nvram ...
37
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 ...
28
votes
How many times can I upload a program or sketch to my Arduino Uno Clone Board?
He's talking complete and utter gibberish. To quote from the ATMega328P datasheet:
High Endurance Non-volatile Memory Segments
32KBytes of In-System Self-Programmable Flash program
...
25
votes
Accepted
How do I convert a float into char*?
There is a function in the standard Arduino library called dtostrf(). I think of it as "Decimal to String Float". You pass in the float, how wide you want the whole number to be (if it will fit), the ...
24
votes
How do I resolve "avrdude: stk500_recv(): programmer is not responding"?
After trying numerous suggestions, 2 different boards, 3 different cables on a WinXP and a Win7 machine, I finally got things working by going to "Tools -> Processors -> ATmega 328P Old Bootloader"
24
votes
Why am I receiving random input values in my Arduino?
You're getting noise pickup on the input pin when the button is not pressed. You need a pull-down resistor, about 10 kΩ to ground, to quiet the noise when the switch is open.
Or even easier, use the ...
23
votes
Accepted
What is an ICSP pin?
ICSP stands for In Circuit Serial Programming, which represents one of the several methods available for programming Arduino boards. Ordinarily, an Arduino bootloader program is used to program an ...
20
votes
Accepted
Does an Arduino get worn out by too much command execution?
No, the code doesn't "wear out" the MCU. In general no matter what you are doing roughly the same level of activity is being performed. Even delay() does lots of work while it's "idling".
There are ...
20
votes
How do I extract code from an arduino?
The short answer: You don't.
With enough know-how, you could probably extract the executable binary from the Arduino, but the source code is not installed on the device. You would need to run a ...
20
votes
Accepted
Is it possible to generate an exact 15 kHz clock pulse using an Arduino?
You can get pretty close if you program Timer 1 directly (not
through the library), and have it run with the prescaler set to 1.
Ideally, you want the period of the timer in clock cycles to be:
F_CPU /...
20
votes
Accepted
Cannot program two arduinos at the same time because they both use the same COM port
I did not knew I could change the port on windows. This is how I did it thanks to @Majenko's comment.
17
votes
Accepted
Only 2 decimal places in printed float
By default, the Serial print function shows only 2 decimals, however I'm sure the float has the full (unrounded) value, even if it does not show it.
You can read about it in the official ...
17
votes
Accepted
Reading several rotary encoders
Library and schematics are at https://github.com/maxgerhardt/rotary-encoder-over-mcp23017.
To read a rotary encoder (i.e., detect state changes of the knob), there are two possible implementations:
...
17
votes
Accepted
What is the default setting for a digital output pin
On the AVR-based Arduinos at least, pins start in the INPUT, i.e. high
impedance state. If you then pinMode(pin, OUTPUT);, the pin turns to
OUTPUT LOW. Note, however, that if you first set the pin to
...
16
votes
Weird multiplication result
Because M(3 + 2, 4 + 2) gets replaced to 3 + 2 * 4 + 2 and then the normal priority of operations does the multiply before the addition.
This is one of the many reasons why you should prefer ...
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 ...
15
votes
Some Arduino components seem ridiculously cheap
The cheaper option is not always lower in quality. You can find items for sale on Amazon, Ebay and Aliexpress that all have the same "seller name" and a identical picture of the item. The price is ...
14
votes
Accepted
Does the Arduino Uno have two crystals?
The ceramic resonator in yellow is connected to the main MCU, and the crystal in red is connected to the other MCU. USB requires tighter tolerances than is available from a resonator therefore a ...
13
votes
Accepted
How to stop uno from running program when powered on?
The simplest thing is to upload the new program before connecting the hardware.
If this isn't practical, connect a jumper wire from the Reset pin to ground (Gnd) before powering it on. This will hold ...
13
votes
Accepted
Why do I get negative voltages for a PWM waveform?
At first you had the scope AC (Alternating Current) coupled. Then you switched it to DC (Direct Current) coupled.
AC coupling is used to remove the DC component of a signal. It places a large ...
13
votes
Accepted
How to output a true analog voltage at output pin
You basically have three options:
Switch to an Arduino Due which has a built-in DAC which outputs a real voltage.
Add an external DAC chip (such as the MCP4821/2) to create the voltage for you
Use a ...
12
votes
Accepted
The difference between "time_t" and "DateTime"
A DateTime is a full class with lots of methods to it - a time_t is just an unsigned long.
time_t is used to store the number of seconds since the epoch (normally 01/01/1970)
The Arduino Time ...
12
votes
Accepted
How to expand program memory on an arduino?
An ATmega2560 is the chip to add for more memory when you run out of program memory on an Uno. Referring to the Memory webpage at arduino.cc, you'll see that it has Flash=256KB, SRAM=8KB, EEPROM=4KB, ...
12
votes
Accepted
ArduinoUNO/MEGA, Is there a way to exceed 256 in analogWrite
Section 16, "16-bit Timer/Counter1 with PWM" of Atmel-8271J-AVR- ATmega-Datasheet_11/2015 describes using Timer/Counter-1 for 16-bit PWM, including sample code in both C and assembler. It might take a ...
12
votes
Different ways (and the fastest) to compute sines (and cosines) in Arduino
The two basic methods are mathematical calculation (with polynomials) and lookup tables.
The Arduino's math library (libm, part of avr-libc) uses the former. It is optimised for the AVR in that it ...
12
votes
Powering an Arduino with more than 5 V
First of all you should read the tech specs for Arduino Uno here:
https://www.arduino.cc/en/Main/ArduinoBoardUno
You will find this important information about power supply:
Operating Voltage 5V
...
12
votes
Accepted
Smaller and cheaper alternative to Arduino Uno for permanent projects
I think the first best choice is to remove the ATMega328p-pu chip from your Arduino UNO and incorporate it into your final circuit.
The chips are only about $1.50.
That way, you can just use your UNO ...
12
votes
Simple multiplication bug
No, this is not a bug. You are using a compile time constant expression which is signed int unless told otherwise. Therefore you can only represent numbers between -32768 and 32767. Your computation ...
12
votes
How do I extract code from an arduino?
You never can get the actual code back ... by reading the flash you might be able to get the executable/runtime code, but this doesn't look at all similar as your code, although it's functionally the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
arduino-uno × 8077serial × 665
programming × 568
sensors × 500
esp8266 × 454
arduino-ide × 376
led × 323
c++ × 283
motor × 283
arduino-mega × 269
power × 239
servo × 222
i2c × 214
lcd × 214
bluetooth × 200
softwareserial × 191
arduino-nano × 173
gsm × 171
wifi × 166
shields × 166
pwm × 165
interrupt × 164
atmega328 × 156
c × 154
pins × 147