Questions tagged [array]

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

277 questions
7
votes
1 answer

Why does Serial.print print only a value for 0-84 for a 100 integer array?

int a[100],i; void setup() { Serial.begin(9600); } void loop() { for(i=0; i<100; i++) { a[i] = i; Serial.println(a[i]); } exit(0); }
Anurag
  • 71
  • 2
5
votes
1 answer

Is it possible to have an array of int arrays?

I have a huge number of arrays, each with a series of numbers each referring to an LED on a strip. I want to be able to address each one by a number, so the logical solution to that for me was to make the whole thing into an array. Can that be done,…
mr-matt
  • 147
  • 1
  • 4
  • 15
4
votes
1 answer

Copy content of array

This may be an easy question, and if so im sorry, but i couldn't find out how to do this. I've programmed in python before and hoped that this would work, but it don't. int myArray1[] = {0, 2, 4, 5, 7, 9, 11}; int myArray2[] = {0, 2, 3, 5, 7, 8,…
landigio
  • 141
  • 1
  • 1
  • 2
2
votes
1 answer

In multidimensional arrays, can you use variable arrays or their names instead of the actual data?

Referring to this thread How to declare and use "Variabled arrays" inside arrays Example byte array[2][4] = { {1,2,3,4}, {5,6,7,8} }; Serial.println(array[0][2]); is equal to '3'. Instead of using {1, 2, 3, 4} and {5, 6, 7, 8} I want to be able to…
AndroidV11
  • 157
  • 5
2
votes
3 answers

How can I initialize an array of objects in setup?

How can I declare an empty global array, to be initialized in setup? What I would like to do is this: #include const size_t ANALOG_SIZE = 3; const int ANALOG_PINS[ANALOG_SIZE] = {A0,A1,A2}; ResponsiveAnalogRead…
RedPixel
  • 123
  • 1
  • 5
2
votes
1 answer

String array glitch

For a project, I was asked to design a presentation on Arduino. I now have run into the problem of my code suddenly stopping. It worked fine one day, I entered a new item in the array, it stopped working. It looked like I was being returned all…
1
vote
1 answer

ArduinoJSON - How to check if array is empty

Parameters file defines the creation of entities and stored in flash. Its structure is given, and all fields ( keys & values ) are given. In current phase - those parameters are hard-coded in a const char* cont_params, as shown below. My goal, is…
guyd
  • 1,033
  • 2
  • 16
  • 51
1
vote
1 answer

Merging two 2-d arrays in order of axes

Looking to merge two different 2D arrays of different row sizes into one long array: int 2dArray1[][] = { {1, 2, 3}, {4, 5, 6}}; int 2dArray2[][] = { {10, 20}, {30, 40}}; int 1dLongArray[10]; This is where I need help in order to…
Hitachii
  • 13
  • 2
1
vote
1 answer

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 instances looks like: timeOUT…
guyd
  • 1,033
  • 2
  • 16
  • 51
1
vote
0 answers

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 readstr; String finalstr; char *messages[][20] =…
1
vote
1 answer

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. new_str gets every time a different…
guyd
  • 1,033
  • 2
  • 16
  • 51
1
vote
3 answers

Why does this array have stored values in it even though I have not put any values in it?

void alarm() { char keypressed4; char keypressed5; char keypressed6; char keypressed7; char disarmcode1[5]; Serial.println("hi2"); Serial.println(disarmcode1); The array gets declared here and I print the values in the empty array. In…
1
vote
1 answer

Changes to array not reflected

Here's a simple sketch. I have an array data and a variable idx. I'm assigning a value to each of the array element, and then sending them to my serial monitor. volatile uint16_t data[5]; volatile uint16_t idx = 5; void setup() { …
bot1131357
  • 113
  • 4
1
vote
1 answer

How to declare and use "Variabled arrays" inside arrays

Good day folks. I'm new here and have been starting to be enthusiast in Arduino. I have a problem and I don't know what I should do, or whether I did something wrong regarding an array of arrays. Surfed on the internet to find a bunch of examples…
Mheruian
  • 123
  • 3
1
vote
2 answers

Extracting char array out of function

I have a array called Table1 witch contains '1','2','3','4' I do not want to work with global variables I want to change the content of Table1 with a function called 'Change' that gives a return char array back in to Table1 This is the program i…
Cyber_Star
  • 117
  • 2
  • 8
1
2