We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [array]

Refers to code that present variables in the form of an array.

Filter by
Sorted by
Tagged with
0
votes
1answer
17 views

How to set current position for the DC motor to zero + store current positions in an array and run it?

I would like to know how to set the current position for the DC motors to zero and store the current position in an array. after that I would like it to loop in the array to run all steps that was ...
0
votes
1answer
46 views

Using Arrays and LED's to represent Piano Scales

I am trying to use addressable LED's to show various piano scales using the semi notes formula for each scale as an array and an input to indicate the starting note. int MajorScale[] = {2,2,1,2,2,2,1}...
0
votes
1answer
35 views

Creating an array with the length coming from a library

When creating an array like in the sketch #include <Lib.h> int myArray[Lib::len]; void setup() {} void loop() {} the variable len must be an integer constant that is known at compile time. ...
0
votes
1answer
26 views

Error: invalid application of 'sizeof' to incomplete type 'int []' when trying to compute the size of an array in a library

I have created a library that contains an array. This is the .h file: class Lib { public: static int arr[]; }; And this is the .cpp file: #include "Lib.h" int Lib::arr[] = {0, 1, 2, 3}; ...
0
votes
1answer
22 views

Compute the size of an array that was passed as a parameter to a function

When passing an array to a function, you usually pass the length of the array along with it. You can compute the size of the array with sizeof(myArray)/sizeof(myArray[0]), which works just fine. ...
0
votes
1answer
56 views

Is std::array (from the C++ STL) safe to use on arduino? Does it use dynamic memory allocation?

I'd like to use std::array on a project that will need to be very stable, and have all memory pre-allocated to avoid heap fragmentation. I am reading in characters from the serial port, following a ...
0
votes
2answers
23 views

How to Sort a String with Number by Ascending

I have trouble figuring out how to sort a String that has a Number in it. The String im sending looks like 112:AAAA and 111:EEEE, how would I sort it so that the 111 will be the first in an array but ...
0
votes
1answer
31 views

Expected unqualified-id before 'public'

I'm making an arduino program for a buzzer that you can record notes and song for and then play them back. I have 2 arrays that hold both pitch and if a note is being played. I continue to get errors ...
0
votes
0answers
34 views

memcpy is corrupting serial output even before call

I just want to memcpy some data into a buffer, but it completely destroys my serial output. Arduino Nano Arduino IDE || VS Code with Platform.io Here the relevant declarations: uint8_t picture[4170]...
0
votes
0answers
29 views

Reading from SD and save it in an array

I have a text file with an IR raw code that I need to read from the SD in order to send it and I don't know how to do it. I tried to use the read file function from the specific SD library but it didn'...
0
votes
1answer
51 views

typedef function pointer array declaration problem

Thanks for all your feedback. It helped. I rewrote this yet another time and this time it works perfectly. I included three variations: a simple example using an array of function pointers, a Lambda ...
0
votes
1answer
76 views

How to scale a bitmap (uint8_t array) in Arduino?

So I have a project where I send text to an Arduino, which is then printed out as a QR code on a thermal printer that can take a bitmap image with a given width and height. Is there a way I can "...
0
votes
0answers
40 views

Fail to obtain Sizeof Array

I have a nested array, but I get only the correct size of the first one. I use this as a reference Arduino sizeOf int clockOn_0 [] = {19,0,0}; int clockOn_1 [] = {20,0,0}; int clockOff_0[] = {6,0,0}...
0
votes
1answer
78 views

How to return Char Array Value in Arduino IDE Function?

Function char* getConnectDetail(int starting){ String data; for(int i=0;i< 1024 ;i++) { if(EEPROM.read(i+starting) != 0){ data += char(EEPROM.read(i+starting)); } } int ...
1
vote
1answer
63 views

Merge two 8 bit arrays to one 16 bit array

I am an absolute newbie to Arduino and C++ and try to go through some tutorials to gain a minimal insight. However I stuck already at some tiny Points. What I want to do? Merge two 8 bit integer ...
1
vote
1answer
102 views

Cannot convert 'int (*)[size]' to 'int**' [closed]

Analyzing this and this answers under Arduino, which should be the proper way to pass a 2D array into a function? The function should be applicable to different sizes of 2D arrays. // NOT COMPILING ...
1
vote
1answer
34 views

Serial Port fails with speeds greater than 19200

In Arduino Mega 2560 R3, properly selecting the Serial Monitor bauds, this code works with #define R 38400, but for some reason, not with #define R 19200 (?), #define R 38400 int rate=R; ...
1
vote
1answer
56 views

How to create array of references?

I have a class named timeOut dealing with timeout tasks. I'm to write a sketch, common for Sonoff basic and Sonoff Dual, meaning that I may have 1 task for Basic and 2 tasks for Dual. Declaring ...
0
votes
1answer
48 views

HardwareSerial Indexing Array

How should I index HardwareSerial ports into a single array?. This compiles, but do not work. HardwareSerial Serials[]={Serial,Serial1,Serial2,Serial3}; void setup(){ for (int i=0;i<=3;i++){ ...
1
vote
1answer
69 views

USing arrays, binary data and bitRead

This is my first manually typed code. I'm sure there may be some glaring "schoolboy errors" in it, so wondered if people could give it the 'once over' In particular, I have never used C++ arrays, ...
0
votes
1answer
225 views

How to programme a button per colour for a neopixel strip?

I am trying to make a particular pixel in a neopixel strip, turn green, red or blue depending which button has been pressed and to stay on until pressed off again (like a toggle), but currently when I ...
2
votes
2answers
247 views

Why does a variable size struct not compile in the Arduino IDE?

This sketch does not compile in the Arduino IDE void setup() { // put your setup code here, to run once: } struct test { int i; char variable[]; }; typedef struct test test; test t = { 0, ...
0
votes
0answers
39 views

problem with char array iteration and strcmp

New to Arduino and programming so forgive me if this is trivial but I've searched and can't find an answer... Goal: I want to convert decimal values to their equivalent fraction... eg: 0.125=1/8. I ...
0
votes
2answers
90 views

How to increase the serial port's data throughput

I have an array of numbers that will be subtracted from the ADC readings of a 50 Hz sine wave. Using Serial.begin(57600);, I can only output 25 samples per sine wave cycle, or about 1,250 samples ...
1
vote
1answer
24 views

Is new.cpp programmed improperly? Arduino 1.8.9

I'm having trouble with my code and I'm not sure if it's a memory allocation issue. So I look at the new, delete to see if it throws errors, and finding the source code I find outrageously simple ...
0
votes
0answers
105 views

sending array of data using spi

am using two arduino uno to start communicating using spi by sending an array of data but actually I having a trouble because the master is only showing me the first byte of the slave's array however ...
0
votes
1answer
51 views

Can't store RFID data in the next 5 bytes of array

I'm working on RFID project to handle multiple cards. I did most of the things OK. But now I have one problem. Which is the following: The RFID code is 5 bytes, so I need an array of 5 bytes. If ...
0
votes
2answers
54 views

Reading Digital Pins and Outputing on entire Ports

I'm very new to coding so please don't grill me. I'm working on a scientific project where I am using a NI-DAQ to digitally trigger mosfets to trigger 300us - 3ms pulses on two high powered LED ...
0
votes
1answer
63 views

Parsing array of an object in a library constructor

I am trying to develop an Arduino library that consists out of two classes. I want 'WayPointStack' to store an array of 'WPCommand', but I can't get it to work. WayPointStack.h #ifndef ...
1
vote
1answer
271 views

Passing arrays, global arrays within functions, pointers, and declaring array sizes

I'm super confused right about now! I've been working on project involving Xbees in API mode, and I need to send different arrays of bytes to the Xbee depending on which buttons I press. Mostly what ...
0
votes
0answers
71 views

How to put the inputs in array?

I face a problem and I really need help. For my Arduino project, I'm using RFID reader with tags. The story is, I have a desired arrangement for the cards and I defined it as an array called desired[]=...
0
votes
0answers
36 views

Problem: char string not working with SoftwareSerial.h

I am creating a program to display text on an OLED display and then have it sent to a thermal printer. The issue is my second char string: word_buffer When I try to use word_buffer for any reason it ...
0
votes
0answers
33 views

passing a char array referance to a methode of a class

I want to set a class for a sensor. One of the attributes of the sensor is an int array that I'd like to pass to a methode to store values in the array. The methode sould be able to write over ...
0
votes
1answer
60 views

Specific formatting of floats and converting them to an array of chars

I have an oled display which can only display 4 digits + decimal point. I need a way to format the number into 4 significant figures; Then I need to convert that into an array of 5 chars (4 digits and ...
0
votes
1answer
47 views

How to convert a delimited string of hex numbers to an int array

I am sending a string to the Arduino via serial, I made the program that sends the data, so I can change it to anything, but for now it sends a string of hex numbers delimited by ':', so for example ...
1
vote
2answers
120 views

Creating an array of structures which store bitmaps to work with u8glib

I've tried reading the documentations and I'm getting desperate because I can't find anything. I need to create an array of structures, which contains a bitmap stored in PROGMEM space (because of ...
1
vote
1answer
748 views

Length of uint8_t* const array

I've an array of type uint8_t* const with 6 items, defined like this uint8_t* const neighbourSet[] = {PEER1, PEER2, PEER3, PEER4, PEER5, PEER6}; Whereas each element in this array is static uint8_t ...
0
votes
0answers
97 views

two dimensional array

how can i store serial port available test to a two dimensional array. strings are separated with Z and end of text with # pls help if anyone alrdy a solution i am posting my program here String ...
1
vote
1answer
339 views

Does Arduino C++ support dynamic arrays of objects

My C++ is seriously out-of-date, and I'm working on a project that will be juggling multiple timed actions at the same time, with a menu system to manage the interface and control those timed actions (...
1
vote
1answer
47 views

Dynamic allocation/ Pointer to Pointer to update an Array containing parameter [closed]

topicArray defined as follows: const char* msgTopic = "Home/Messages"; const char* groupTopic = "Home/All"; char* deviceName = deviceTopic; const char* topicArry[2] = {deviceTopic, groupTopic}; But ...
0
votes
0answers
86 views

How to store an array of doubles? As array of doubles, Strings or const char *? Then convert back to use?

This seems like an old, solved problem, but I can't find any simple answers. I'm reading latitude and longitude data as Strings from a file (about 50 points), but they are really double float numbers. ...
0
votes
1answer
42 views

Message Interpreter and Handler - How to store a function name in a struct?

For a project, I need to store an array of structures in PROGMEM. Array MessageTable[] will be composed of about ten struct InMessage elements. InMessage looks sort of like this: struct AvcInMessage {...
0
votes
1answer
52 views

Stacks on arrays on arrays

I am trying to find a "vanilla" way of writing several arrays into one. I spent a lot of time searching for how to do this but everything that comes up is either a tutorial that doesn't cover ...
1
vote
1answer
126 views

Initialize and read from a PROGMEM array of pointers to PROGMEM arrays

I'm working on a project for the arduino uno for which I need multiple constant arrays of bytes. Such an array is initialized like so: const byte charR[] PROGMEM = { B01111111,//top half ...
0
votes
2answers
88 views

Assigning array variables to int variables

I need to control thousands of rgb leds.To make animations I want to assign led numbers(addressable led strip) to arrays.For example floor[2]room[14]=106 106 is the number of led,there are many floors ...
0
votes
1answer
71 views

Arduino Object Array initialization

I just got an Idea of trying to code rain simulation with arduino and Adafruit OLED display. When I finished it was quite messy code so I thought That maybe doing it Object Oriented would help. This ...
1
vote
1answer
388 views

Remove all items from an array [closed]

i'm trying to remove all the data i've in an array. Example: I've arr[5,3,2] and i want to clear the array totally and finish with an array like this arr[], ready to add new values. How can i do that?...
1
vote
1answer
97 views

Splitting a message

I have a string to be splitted into define chunks. For example new_str="abcdefghjklmnopqrstuvwxyz, and my goal is to split it to chunks of split_size=5, so the result should be :abcde,fghij and so o. ...
2
votes
1answer
75 views

Help with AlphaNumeric array

I have a Leonardo board and I want to set up my pins to input in one shot using a for loop but the problem is with the analog pins I can't see how to set up a mixed alphanumeric array it gives me some ...
1
vote
2answers
119 views

ArduinoJSON: Using a reference to a reference when parsing array of arrays

I started to play around with the ArduinoJson library to parse data I got from one of my APIs (the format of the JSON data I get from my API can be improved for sure, but the software I had to ...