Most Popular

1500 questions
10
votes
1 answer

A digital I/O pin as ground

I want an I/O pin to return current in a circuit, similarly to the function of ground. Which of these will achieve what I require? pinMode(pinnumber, OUTPUT) digitalWrite(pinnumber, LOW) or pinMode(pinnumber, input)
rajat
  • 203
  • 1
  • 2
  • 7
10
votes
4 answers

Arduino motor shield orange/white pin usage

I have an Arduino motor shield like this one plugged into my Mega board. I would like to know some more information about the orange and white pin blocks on the board. The Arduino website has the following information, but it doesn't give any…
bladepanthera
  • 376
  • 2
  • 3
  • 14
10
votes
5 answers

formatting strings in Arduino for output

I wander what is the best option for formatting strings in Arduino for output. I mean what's a preferable way in the point of view of performance, memory usage – things like that. I see, people usually use direct Serial.print/println, like this: …
zhekaus
  • 439
  • 2
  • 6
  • 16
10
votes
1 answer

Arduino Convert std:string to String

I'm working on BLE project with espressif library. And It returns me founded BLE device. std::string getManufacturerData(); std::string getName(); int getRSSI(); BLEScan* getScan(); When I want to print device name to serial port…
BK52
  • 203
  • 1
  • 2
  • 4
10
votes
1 answer

Arduino IDE and subfolders

I have a sketch with multiple source files and folders arranged like so. I've divided up the project like this to keep things clean. | \---project | project.ino | types.h | +---sub1 | gadget1.c | gadget1.h …
user3404036
  • 101
  • 1
  • 3
10
votes
1 answer

Adding a custom board to the Arduino IDE

I would like to know what is the procedure for adding a custom board to the Arduino IDE? My custom board is similar to the Arduino Zero. Instead of using the ATSAMD21G18, my board is based around the ATSAMC21G18. I also have the Atmel/Microchip…
sa_leinad
  • 3,188
  • 1
  • 22
  • 51
10
votes
1 answer

Setting timer3 in CTC mode - conflict with servo library

I would like to set up a timer in order to call a function 800 times per second. I'm using the Arduino Mega and Timer3 with a prescaler of 1024. To choose the prescaler factor I've considered the following steps: CPU freq: 16MHz Timer resolution:…
UserK
  • 559
  • 1
  • 11
  • 24
10
votes
3 answers

What is the difference between declaring a variable outside of loop and declaring static inside loop?

These are two ways I can hold a variable outside of loop (or any function). First, I can declare it with global scope outside of loop: void setup() { Serial.begin(9600); } int count = 0; void loop() { Serial.println(count); count++; …
Cybergibbons
  • 5,350
  • 7
  • 33
  • 51
10
votes
1 answer

Reading several rotary encoders

Have an upcoming project where user input will be based on spinning a large cog and I have several UNOs available Since rotary encoders need two pins, only a Mega would be able to handle the 7-8 encoders needed. Unless theres a better method of…
Andrew Lazarus
  • 243
  • 1
  • 2
  • 7
10
votes
1 answer

CH340 Nano avrdude: stk500_getsync() not in sync resp=0xa4

I'm trying to upload some code to an non-arduino nano with the CH340G chip, and the avrdude refuses to let me upload. The error I'm getting is: Using Port : COM4 Using Programmer : arduino Overriding Baud Rate …
Jacob
  • 219
  • 1
  • 2
  • 6
10
votes
1 answer

How to reset Arduino from software

As you know, the Arduino IDE resets the Arduino when the Serial Monitor is opened. I want also my program to do it. But I don't know how. I examined the source code of the Arduino IDE (Serial.java & SerialMonitor.java), but I can't find where it…
Bhoke
  • 321
  • 3
  • 11
10
votes
1 answer

What does the line "while (! Serial);" do in an Arduino program?

I'm new to Arduino, and I am trying a couple of tutorials. What does this line do in a program? while (! Serial);
Brendan
10
votes
1 answer

Counting pulses with interrupt

I have been trying to count pulses from a 12,500 Hz square wave to trigger an output. Here's the code I have so far. When the Arduino is reset it prints 315 to the serial over a 25 ms sample. 315 x 40 = 12600. Which seems to me it's working…
Brandon Whosville
  • 103
  • 1
  • 1
  • 5
10
votes
3 answers

How can I program an arduino in pure C/C++?

I am a beginner and I want to learn AVR C/C++. Can I do this using an Arduino? (I'm asking this because I already have one). If so, could someone tell me using which IDE can I write code in pure C/C++ and then flash it to the Atmega328P on the…
ICRed
  • 101
  • 1
  • 1
  • 3
10
votes
4 answers

What is the proper way to make library pin mappings configurable?

I am working with some libraries that provide APIs for interacting with specific hardware chips (that makes these drivers?). However, different custom boards or shields will have the chip mapped to different pins meaning the library needs to be…
vossad01
  • 203
  • 1
  • 6