Questions tagged [array]
Refers to code that present variables in the form of an array.
280 questions
14
votes
3
answers
52k
views
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?
...
7
votes
1
answer
2k
views
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);
}
7
votes
3
answers
23k
views
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 ...
5
votes
3
answers
1k
views
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(){
...
5
votes
1
answer
29k
views
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 ...
5
votes
4
answers
4k
views
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 ...
5
votes
3
answers
6k
views
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 ...
4
votes
2
answers
19k
views
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 ...
4
votes
2
answers
899
views
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 ...
4
votes
1
answer
29k
views
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, ...
3
votes
1
answer
9k
views
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%%",...
3
votes
3
answers
25k
views
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 }...
3
votes
2
answers
8k
views
Iterate an Object Array
I'm trying to create an array of objects and later iterate over it and do something with each object. My C++ skills just don't go far enough.
Here's what I have so far. I've tried to strip out all ...
3
votes
3
answers
7k
views
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 ...
3
votes
2
answers
508
views
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 =...