Questions tagged [array]

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

280 questions
14
votes
3 answers

Returning an int array from a function

I have a function that needs to return 3 int values. I currently use an array declared in the global scope and I ask the function to write into them. Is there a way to make a function return an array? Here is what I want to do: int function() { int…
Dat Ha
  • 2,943
  • 6
  • 24
  • 46
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
7
votes
3 answers

Replacing several pinMode() and digitalWrite() pins with an array

I'd like to 'clean up' some code that involves several pinMode() and digitalWrite() lines by using a single line of an array. I'm very new to both arrays so I'm a bit confused. The following examples are sections from code that controls a 4 digit, 7…
zdub
  • 141
  • 1
  • 2
  • 8
5
votes
3 answers

Sizeof variables and Due's RAM

I set out to see how much space some arrays have. I used this test code bool state = false; uint16_t BuffA[46000]; uint16_t BuffB[20000]; uint16_t BuffC[20000]; uint16_t all = 0; void setup(){ Serial.begin(9600); } void loop(){ if…
user1584421
  • 1,425
  • 3
  • 26
  • 36
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
  • 5
  • 15
5
votes
4 answers

Employing C++ code for Arduino

I have Googled quite a lot regarding using a C++ program for uploading to Arduino and related, however I am confused now. Right, my problem is this: I have written a C++ program which imports RGB data of a 24 bit bitmap (which was generated using…
panda_the_great
  • 97
  • 2
  • 10
5
votes
3 answers

Works with gcc, not with Arduino. error: taking address of temporary array

I need to hard code 8 byte addresses into char arrays of length 8. This must be done many places in my code (in function scope), so I have tried to come up with a one-liner. The following works perfectly in C when compiling with gcc. char…
Mads Skjern
  • 1,145
  • 3
  • 13
  • 23
4
votes
2 answers

Initializing Array of structs

I defined myself a struct: typedef struct { unsigned char current; unsigned char start; unsigned char target; unsigned long startTime; unsigned int duration; } led; I was able to initialize an instance of that like this: led h_red =…
iGEL
  • 143
  • 1
  • 1
  • 4
4
votes
2 answers

Image Breakdown

I've been trying to figure out a way to store an image on the Arduino, and I couldn't figure it out. What I've been trying to do with this image is the following: Test that the arduino has the image by displaying on a touchscreen (I have the…
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
3
votes
2 answers

Form a signal from an array of bits

I need to reproduce with a digital pin of an Arduino such a key in the form of a sequence of 1's and 0's, where a one takes 2 ms high and 2 ms low, and a zero takes 1 ms high and 1 ms low. int key = 0b101100001111; void setup() { pinMode(13,…
Антон
  • 265
  • 3
  • 10
3
votes
3 answers

How to get the sizeof array of structs

I'm trying to make a use of a relay module, I want a clear way to configure and control my relay module I've defined the struct and filled it with some info about id, pin number, title, and relay state I can't loop with for in the array of controls,…
Moktar
  • 31
  • 1
  • 2
3
votes
1 answer

Arduino Nano IoT 33 Char Array size constraints

I would like to save data that I am receiving from API calls in a char array. The problem is that the data is around 80 kB, and my Arduino IoT 33 only has 32 kB of memory. It will save data in a char array up to 25000 bytes, but when I go to 30000…
Amir
  • 41
  • 3
3
votes
1 answer

How to get char array's length

I use a LCD display to display a not known size of text ( changes over time ). I wish to display it at the center of LCD ( 2X16 ). I declare: char t[16]; char h[16]; sprintf(t, "%.1f%cC %.0f%%", temperature,223, humidity); Now, since I want…
guyd
  • 1,049
  • 2
  • 26
  • 61
3
votes
3 answers

How can I concatenate multiple byte Arrays into one Array

I have three byte arrays. I first change their values during runtime and after that I want to combine them into one bigger 4th array. byte a1[] = { 0x01, 0x00, 0x01 }; byte a2[] = { 0x00, 0x11, 0x01 }; byte a3[] = { 0x11, 0x00, 0x01 }; byte c1[] =…
William Roy
  • 515
  • 4
  • 10
  • 22
1
2 3
18 19