Questions tagged [arduino-mega]
A microcontroller board based on the ATmega2560 or 1280 chip. Use this tag for questions specifically regarding the Mega, and not just general Arduino usage.
1,822 questions
71
votes
12
answers
458k
views
How do I split an incoming string?
I am sending a list of servo positions via the serial connection to the arduino in the following format
1:90&2:80&3:180
Which would be parsed as:
servoId : Position & servoId : Position &...
29
votes
8
answers
21k
views
Are global variables evil in Arduino?
I'm relatively new at programming and many of the coding best practices I'm reading effectively state that there are very few good reasons to use a global variable (or that the best code has no ...
17
votes
1
answer
159k
views
Convert int to char[]
I'm looking to convert an int value to a char array. currently I've found the following will return [number]
int num = [number]
str = String(num);
str.toCharArray(cstr,16);
Serial.println(cstr);
...
13
votes
3
answers
27k
views
Arduino Mega timeout communication with programmer error
I have an Arduino Mega 2560 and it was working fine until about lunch time when I started getting this error:
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout ...
11
votes
4
answers
10k
views
What is the cheapest way to add wifi to Arduino?
I am trying to find some sort of wifi adapter for Arduino, it needs to be as small as possible (not a shield) and as cheap as possible.
So far I can only seem to find shields that cost about £10+ ...
10
votes
1
answer
19k
views
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 ...
10
votes
4
answers
8k
views
How to interconnect multiple Arduinos with a Rpi to control home-lights/switches
While planning the lightning infrastructure (wall-switches and lights) of my new home (it's still under-construction) I choosed to go through the "automated route" way and due to my background (I'm an ...
9
votes
2
answers
4k
views
How to update a variable in an ISR using Timers
I'm trying to check the frequency of Timer3 using a counter. The value of the counter, declared as volatile, is incremented in the ISR and every second the sum is shown in the main loop and the value ...
9
votes
2
answers
20k
views
What is the maximum wire length for serial communication between two Arduinos?
I am building a project in which two Arduinos will be linked by three wires: TX an RX for serial communication and a common GND. What would be the maximum length of the wires here before communication ...
8
votes
2
answers
4k
views
OOP vs Inline with Arduino
I have been programming for quite a while now but I am new to Arduino and AVR Programming. The main question I have about programming these Micro-controllers is are there major differences in ...
7
votes
5
answers
5k
views
What is the best technique to design a 20 push button circuit
I will be controlling a robot with more than 10 motors which means I'll need 2 buttons each to control moving forward and backward. My controller is an Arduino mega. Is 1 pin = 1 button the best ...
7
votes
3
answers
5k
views
Advisability of Using Bit Fields in Structs
I have to track a large amount of data (for an Arduino) in a program while taking care of a fair amount of other business.
I started with a struct like this:
struct MyStruct
{
// note: these ...
6
votes
2
answers
488
views
What is the circular gold pad on arduino mega 2560 v2 and above?
Could someone point me to the documentation that describes the gold dot and surrounding gold circle on the front of my arduino mega v2 board. It is right above the ICSP header and reset button, and ...
6
votes
2
answers
17k
views
How to choose between AM230x and DHT22 temperature and humidity sensors?
I'm looking forward to getting an accurate humidity and temperature sensor.
Right when I decided to go with a DHT22 module, I saw AM230x (AM2301, for example).
How do I choose between DHT22 and ...
6
votes
1
answer
8k
views
How do I specify a working directory when saving to SD card?
I'm trying to datalog to a EyeFi SD card by writing to a file with a jpg extension. Here's that portion of my code so far:
// see if the directory exists, create it if not.
if( !SD.exists("/DCIM/...
6
votes
1
answer
859
views
Arduino Digital Input Causing Output Problems
I am working on a simple project using an Arduino Mega 2560 that involves reading a 12-bit binary encoder signal and which is used to cycle a digital pin high and low (depending on the angular ...
6
votes
1
answer
320
views
Why do MEGA2560 digital pins go high on serial disconnect?
I'm trying to set up a system using an that delivers a specific number of digital pulses to a device using one of the digital pins. The number of pulses delivered is specified over a the Mega's USB ...
5
votes
1
answer
14k
views
Arduino Countdown without using delay()
I am working on a project which requires countdown from 30sec to 0sec. I can't use delay() function because I am taking input from keyboard during countdown. millis() function wont help because my ...
5
votes
1
answer
924
views
Delay() and millis() functions don't work in cpp external files
I'm currently facing an issue using delay() and millis() functions in an external cpp file.
The issue is that when I used delay() in my main program (meaning .ino file) it works well but when I call ...
5
votes
1
answer
18k
views
Arduino /dev/ttyUSB0 permission denied even when user added to group "dialout' on Ubuntu 18.04
I bought Arduino Mega board (CH341 usb) and I am able to connect to /dev/ttyUSB0 (upload to device) only by using sudo.
OS: Ubuntu 18.04
What I've tried:
I have downloaded Arduino IDE and added my ...
5
votes
1
answer
12k
views
Wrong documentation for Mega2560 SPI Pins?
This page https://store.arduino.cc/usa/mega-2560-r3 contains an image under the Documentation section which shows digital pins 10 to 13 with labels SS, MOSI, MISO, and SCK.
EDIT: The documentation ...
5
votes
3
answers
20k
views
How to clear FIFO buffer on MPU6050?
my MPU6050 works very unstable , the problem is unable clear excessed FIFO buffer on MPU6050, I am using Jeff Rowberg's MPU library and according to his DMP example but without using interruptions,...
5
votes
2
answers
1k
views
Analog read negative voltage inbuilt protection
I'm trying to read a -10 to +10V analog signal on my Arduino Mega (2560). I've been using a voltage divider to obtain a -5V to +5V signal (with two 10kOhm resistors), which used to work just fine.
I'...
5
votes
2
answers
220
views
How to move my robot in the right direction?
After all there is more question poping up then answers i decide to upload the pdf where is everything writen, like the wire, motor type and what we can and can't use. Here is the link pdf format of ...
5
votes
2
answers
11k
views
Simulation of Arduino Mega 2560 with GSM Module using Proteus
I have really been suffering with my simulation! Tried connecting my arduino mega 2560 to COMPIM (used as GSM Module) in my circuit and also loaded sample code but damn! In vain! I wanted to view the ...