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,821 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 &...
67
votes
2
answers
231k
views
How do you use SPI on an Arduino?
With reference to the Arduino Uno, Mega2560, Leonardo and similar boards:
How does SPI work?
How fast is SPI?
How do I connect between a master and a slave?
How do I make an SPI slave?
Please note: ...
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 ...
29
votes
8
answers
40k
views
How can I get a unique ID for all my Arduino boards?
Once you have uploaded a sketch to one of your Arduino boards, it is hard to know exactly what source code led to that sketch.
Indeed, you may change the source code of your sketch on your PC without ...
17
votes
1
answer
160k
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);
...
15
votes
2
answers
37k
views
What are the fundemental differences of different Bluetooth modules for beginners?
I'm a beginner to microcontrollers and electronics, albeit not really to computers and programming.
Starting out with the Arduino, I came to a point whereby I'm really interested in getting my ...
13
votes
3
answers
28k
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
2
answers
22k
views
3.3V, 5V and 9V pins on Arduino
On my Arduino Uno R3 and Arduino Mega R3, there are 5V and 3.3V pins.
However on this page Introduction to the Arduino Board, there is a 5V and 9V pin but no 3.3V pin. The page at Arduino: What ...
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
5
answers
7k
views
Can I make delayMicroseconds more accurate?
I'm trying to bit bang DMX data and that requires 4us pulses. Not having much luck with the results I'm checking to see how good the Arduino is at delaying... Seems to be pretty terrible at it.
Here'...
10
votes
1
answer
20k
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
33k
views
2.4" TFT LCD Shield isn't working on Arduino Mega
Even on ebay's website it is mentioned that I can't use 2.4" TFT LCD Shield display on attach to Arduino Mega. The problem is that I bought this shield by mistake. I want to put this shield onto ...
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 ...
10
votes
1
answer
4k
views
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 ...
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
1
answer
789
views
Can you query the current serial port's speed?
Is there some code I can use to find out what the a chosen serial port's speed is running at ?
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
3
answers
42k
views
Arduino Due vs Mega 2560
What can an Arduino Due do that a Mega 2560 can't? What can a Mega 2560 do that a Due can't? I've heard the Due is 3.3V so it can't work with most shields.
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 ...
8
votes
1
answer
4k
views
Event driven programming
I have ran across a couple of different event libraries that are available on the AVR and Andruino but I am not sure which one is the best option. What I would like to do is design my program in a ...
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
1
answer
2k
views
What are these stray resistors on the Arduino Mega schematic?
I am using the Arduino Mega schematic found here and it's mostly clear, but there are a few resistors floating in the middle and I'm not quite sure what they're for or where they go:
Does anyone know ...
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 ...
7
votes
3
answers
31k
views
I2C 2 way communication between Arduino Uno and Arduino Mega
If I remove the transmission code from slave this works properly but I need to transmit from slave.
Here is my master code
#include <Wire.h>
void setup() {
Wire.begin(3);
Wire.onReceive(...
6
votes
2
answers
493
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
1
answer
2k
views
PWM signaling with Arduinos: What is the reason for the ground connection?
This may sound like a very dumb question and I apologise in advance.
I've gone through reading about PWM and working on some example sketches to control PC fan speeds using PWM and Arduino.
In all ...
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
4
answers
553
views
Why/when to use IoT publish/subscribe protocols rather then RESTful HTTP?
I am sending data (GPS coordinates) from Arduino once a minute with HTTP POST request to REST API (in OpenShift PaaS). Data is then stored to MySQL db.
Would so called "IoT" publish/subscribe ...
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
3
answers
13k
views
Arduino Hardware serial library with rts/cts flow control support
Does there exist (any user developed etc.) version of the Hardware UART serial library that has support for RTS/CTS based flow control?
More interested in the Tx side (Arduino sends data, while the ...
6
votes
1
answer
875
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
9k
views
References (e.g, libraries and tutorials) for connecting the 24-bit ADS1256 ADC to arduino
The ADS1256 chip is a high precision 24bit, 8 channel, analog digital converter based on SPI communication that is suitable for biomedical applications and perfect for sensing ECG and EEG signals. I ...
6
votes
1
answer
329
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 ...
6
votes
1
answer
10k
views
Connection problem with Arduino Mega 2560 and GSM shield ( official M10)
As I don't want to stack the shield over the mega 2560 board, I try to connect only the pins that used for GSM communication. Here are my connection:
Pin 3 on Mega <==> Pin GSM Rx on Shield
Pin ...
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
2
answers
5k
views
16x2 LCD showing blocks under text
I have a LCD connected to a Arduino Mega 2560 using the instructions in LiquidCrystal library. It is not the first time I am using a 16x2 LCD but I never have encountered a problem like this. When I ...
5
votes
1
answer
938
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
3
answers
16k
views
How to read bitmap image on Arduino
I want to convert a bitmap into binary array. My bitmap image is 272*208 pixel monochromatic 1bpp image. I'm confused when the width I get from my image is 16 instead of 272, the height is corrected. ...
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
3
answers
4k
views
Entering integers as bytes in serial monitor
I am doing some byte manipulation in Arduino, but when I enter an integer into the serial monitor, such as 1, and my program stores it as byte incomingByte, the value stored in incomingByte is 49 and ...
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
2
answers
1k
views
How to deal with unusual neopixel grid
I have built a custom installation in my home with 896 WS2812 LED driven by an ArduinoMega 2560 and powered by several rails just fine. However, the installation is arranged in a checkerboard-like ...
5
votes
3
answers
21k
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
1
answer
30k
views
ov7670 + Sd Card + arduino
I have three devices for making a motion activated security camera system:
this is the camera : LINK OV 7670
this is the SD Card module: LINK
and a basic motion Sensor: PIR with 3 pin
I have an ...
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
1
answer
13k
views
How to generate gcode for Arduino Mega 2560 and Ramps 1.4 CNC Router [closed]
I had a Prusa I3 3D Printer which use Arduino Mega 2560, Ramps 1.4 and Pololu - A4988 Stepper Motor Driver.
I want to convert my 3D printer to CNC Router using my Dremel with Flexible shaft like this.
...
5
votes
2
answers
230
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
1
answer
5k
views
ArduinoMEGA: 64 digital inputs cause random digitalRead values
I have 64 hall effect sensors (magnetic field sensors) (DRV5023AJQLPG) connected to an Arduino MEGA 2560. For that, I use 48 digital pins and 16 analog pins as digital input pins. The program in the ...
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 ...
5
votes
1
answer
2k
views
How to make XBee module interrupt/wake arduino
What I am trying to do is, to have arduino in low power mode and waking up only when a packet is received and is available to be read from the buffer.
A scenario : Zigbee XBee module is not ...