Questions tagged [array]

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

270 questions
13
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,883
  • 6
  • 21
  • 44
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
  • 1
  • 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,349
  • 3
  • 19
  • 32
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
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,085
  • 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
  • 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…
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
  • 2
  • 9
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

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
  • 898
  • 1
  • 13
  • 39
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
  • 495
  • 3
  • 10
  • 22
3
votes
2 answers

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 the meaningless code. Whats wrong is my tr object is…
HK1
  • 367
  • 1
  • 4
  • 10
3
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
  • 131
  • 1
  • 1
  • 2
1
2 3
17 18