Questions tagged [array]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
52 views

Why are characters with value above 127 “padded” with 1s to be 16 bits long, while ones with values 0-127 aren't?

I am using the Arduino IDE to run and monitor, with an Arduino Nano clone. This code shows what I mean by the question: char foo = 127; char bar = 128; Serial.println(String(foo, BIN)); Serial.println(...
2
votes
2answers
56 views

strcmp doesn't seem to work

I'm trying to compare a char array that I'm assembling to a string and I'm having trouble comparing the strings. I'm getting the data for the char array as a set of bytes and I'm compiling it into a ...
2
votes
2answers
252 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 ...
1
vote
2answers
55 views

How to add two assembly arrays in arduino

Hey guys what I'm trying to do is to sum two arrays and return a new array; for example if given uint8_t a[] = {2, 4, 6}; uint8_t b[] = {1, 2, 3}; I should get { 3, 6, 9} What I'm trying to do is ...
1
vote
1answer
71 views

Storing and sequencing output value (arduino)

I am new to Arduino programming, after days and nights trying to use array,for loop and googling a lot of article, I still unable to find the way how to store each weighing output value from int ...
0
votes
0answers
39 views

trouble finding peaks from pitch using IMU BNO080, 'array' was not declared in this scope not displayed

{ if (myIMU1.dataAvailable() == true) { float x1 = myIMU1.getGyroX(); float y1 = myIMU1.getGyroY(); float z1 = myIMU1.getGyroZ(); Serial.print(x1, 2); Serial.print(F(" &...
-1
votes
1answer
32 views

RF24- Splitting and sending a longer than 32 byte payload

In order to send a long payload I've created the following function: void splitMSG(const char *msg, const int arraySize, const int len) { Serial.print("Array size: "); Serial.println(...
1
vote
2answers
95 views

Unexplained behavior of char array after using `deserializeJson`

I'm using RF24 library to send messages between 2 MCU's : 1) ESP8266 (no Wifi, same code can be compiled to any Arduino board) 2) pro-Micro. Message is sent in JSON format, while using ArduinoJSON ...
1
vote
1answer
30 views

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 ...
3
votes
2answers
203 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 =...
3
votes
3answers
111 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 ...
0
votes
2answers
80 views

Float array to comma separated string

I have a loop command reading temperature sensor data from 8 thermistors and are storing them as floats into an array. Instead of printing to Serial on each iteration, I would like to create a comma ...
2
votes
1answer
19 views

iterate through 8 thermocouple sensors (MAX31856)

I have 8xMAX31856 and I am trying to use the Adafruit library. Instead of writing all 8 thermocouple channels each time in code (and wasting memory), I want to store the objects in an array and loop ...
0
votes
1answer
69 views

Passing a time_t array as a function parameter

I'm trying to log reconnections and disconnections of a network. For that I've created 2 time_t arrays to store such occurances: const int logSize = 10; time_t conLog[logSize]; time_t disconLog[...
1
vote
0answers
42 views

How could I combine sensor data with custom protocol und send it with Serial?

I am very new to Arduino. Now I am trying to send the sensor data to Computer. The sensor data will be stored as bytes into arrays. To build a robust transmission I'll pack the data with own defined ...
1
vote
1answer
35 views

Arduino array error

I'm writing a program that has a sub program that saves values to an array, but the sub program that saves the values to the array comes back with an error telling me that the array isnt declared in ...
0
votes
3answers
80 views

What's the most direct way to assign Serial.read() bytes to an array?

I'm trying to send NMEA 0183 sentences through LoRa. Every dinstict NMEA message looks like several char arrays (sentences) followed by '\n'. In the below picture we see one NMEA distinct message: ...
0
votes
1answer
56 views

Best strategy to parse 5 byte arrays to find a pattern

Ok here it goes, my first ever question posted to stackexchange! Please be gentle on me! I am using an Arduino UNO (at the moment, will move to a faster micro later - but still use an Arduino sketch) ...
0
votes
0answers
74 views

arduino split string into an array [duplicate]

i have problem with change srting to array my string input is like this B109DAE1B71B638E it come from Serial.readString and i want to change this string to array byte like this byte in01[] = { 0xB1, ...
0
votes
0answers
31 views

Size limitation on char Array on ESP8266

I'm creating a log of events, stored as a txt file. If it matters, I'm using ESP8266. To display the log of each IOT, I'm publishing the txt file to a disgnated MQTT topic for all my IOT devices (...
0
votes
1answer
32 views

String array length in function

I know this question has been asked a thousand times, but I can't find a solution for my case. I what to get the length of a string array in a given function. This is for an arduino board. #define LEN(...
0
votes
1answer
26 views

Check if any of loop's insides returns 1 and hold it until the whole loop is 0 again

I'm new to this, so, please, don't crucify me. I have a function that checks if an entry in multilevel array is in a certain range. Using FOR loop I check the whole array with this function, which ...
1
vote
3answers
349 views

using a switch case with a 5-position switch and serial output

I'm trying to get started on developing a menu system for my LCD1602. I have a Parallax 5-position switch (up,down,left,right,center) and I would like to interface the two. I've been trying to get ...
0
votes
1answer
141 views

How can I assign the value of a char array to a uint8_t array?

I have a char array variable that has a value. I need to send this value through LoRa. The library I use for the LoRa implementation accepts an array of uint8_t. How can I pass the value of a char[] ...
-3
votes
1answer
116 views

Any limitation on array size in Arduino Mega 2560?

I am writing an Arduino code with 3 arrays. Two of those are double and other one is int. Further first two arrays have nearly 420 elements for each. Now I noticed that with more that 89 elements on ...
1
vote
2answers
129 views

How do you remove an item from array arduino?

Is there a way that can change {3, 5, 3, 6} to {3, 5, 6} with a function? I checked all the arduino forums but they don't give the answer i need (just delete 1 item from an array with a function like ...
1
vote
1answer
32 views

How do you make a Class variable array bigger?

I am making an infrared macro-keyboard, I want to store Unicode for the Keyboard class in an array inside a class I made called Keybindand to allow the user to program as many outputs as they want, I ...
0
votes
1answer
332 views

Need help with EEPROM not storing array values on ESP8266 after restart

I am struggling through a program. I am trying to store my uploaded string into an array then write that array to EEPROM. I run the program, upload the new array and store it in the EEPROM. all values ...
0
votes
1answer
182 views

Setting an array pointer to null on declaration

How can I set an array pointer to null? I have a pointer to a 3 int array that I am trying to set to null. int (*EXCLUSIVE_COLOR)[3]; Per this link I was trying to set it to null upon ...
0
votes
1answer
53 views

Assigning an empty array row to reference [duplicate]

int colors[][3] = { { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 }, { 253, 7, 210 } }; int (*EXCLUSIVE_COLOR)[3]; I have a two-dimensional array to store some color values. I have a 2nd ...
0
votes
2answers
53 views

Assigning an element of a multidimensional array to a second array

I have two arrays. The first array is a multidimensional array holding color values. The 2nd array stores an active color from the 1st array. How can I assign an element from the multidimensional ...
0
votes
2answers
127 views

ESP32 runtime error in 2d array

I am trying to serial print the value of b[0][0]. Has to be zero but it dose not work! Here is the code void setup() { Serial.begin(115200); byte b[321][241]; Serial.println(b[0][0]); } void ...
0
votes
1answer
100 views

Error taking address of temporary array when passing compound literal array

I have an Arduino sketch that passes an array into a method as a compound literal, but for some reason I keep getting the following error: void setup() { } void printConcatLine(char chunks[][20]) { } ...
1
vote
2answers
52 views

Nothing received from function returning array of strings

My read function returns an array of strings. i.e ssid and password String* configuration::read() { String rw_ssid = ""; String rw_pswd = ""; const int keys = 2; String read_ssid_pswd ...
0
votes
1answer
231 views

Getting error invalid conversion from 'const char*' to 'const uint8_t*

I have written this sketch, and I am trying to populate the array of wifi hotspots to set the value in html select using javascript dynamically. #include <Arduino.h> #include <Hash.h> #...
0
votes
1answer
43 views

Swap two arrays (using pointers, not copy)

I've got two arrays, defined as: uint8_t array1[10]; uint8_t array2[10]; I'd like to swap the arrays (actually the pointers to each array) using code like this: uint8_t *tmp = array1; array1 = ...
0
votes
1answer
162 views

Scrolling an I2C text

I want tried to make a programm to display a text on an I2C LCD-Display. The text should be scrolled for one position every time the function is called. On the internet I saw a lot of solutions but ...
1
vote
2answers
41 views

An array of existing arrays

I have a bunch of 3D arrays in the following form: byte lines[][4][2] { { {B00000000, B11110000 }, {B00000000, B11110000 }, {...
1
vote
1answer
68 views

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 the data is around 80KB however my Arduino IoT 33 has 32KB of memory. It will save data in a char array ...
0
votes
1answer
32 views

Why when I pull an EEPROM index the value returned is garbage?

I have an array of colors for my tft screen: const uint16_t colorTheme [] PROGMEM = {BLACK, WHITE, NAVY, CYAN, RED, GREEN, VERDEAQ, PINK, ORANGE, PURPLE, GRAY, YELLOW}; When I try to use colorTheme [...
0
votes
2answers
35 views

Regarding Strings and assignments

I have this code which works : String ErrorMsg; ....... if(!UploadPacketError) { ErrorMsg="OK"; } else { ErrorMsg="NOK"; } String creates a dynamically allocated array which I want to avoid. ...
0
votes
2answers
364 views

Reading from SPIFFS - What's the best way to deal with a string (or char) array with undefined length?

I've read that it's best to avoid using String in Arduino so I'm ready to use a char array if it's better. I'm reading the file names from an SD Card and my goal is to store them in an array and then ...
0
votes
0answers
43 views

Multidimensional array with date and numbers

I would like to create something similar to a multidimensional array. I would like to get this effect. setting = [ 0 => [// 0 is the day of the week, but it can be a number '1:25' =&...
0
votes
2answers
210 views

Replacing large lookup table with switch statement

My arduino needs to take a 14-bit number and convert it to a 10-bit number. Can't use a formula for it since the data is quite random. So I created a lookup table with 2^14 elements, each containing a ...
0
votes
2answers
67 views

How do I make a character array scanner properly?

I start with this: char delay_chars[10]; then I have a stream of incoming characters that I need to assign like this: ['I', ' ', 'l', 'o', 'v', 'e', ' ', 'p', 'i', 'e'] I can do that, but then ...
0
votes
2answers
1k views

Declaring and using array of structures in Arduino

Printing structure variables, I get default values. What is wrong with my code? struct SCENARIO { int Lamp_Pin = -1; int PB_Pin = -1; } ; SCENARIO _red; SCENARIO _yellow; SCENARIO _white; ...
2
votes
1answer
991 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%%"...
0
votes
2answers
322 views

How to create an array from serial.read?

I'm working on a audio-reactive lightinstallation with 16 LED lights. In Max MSP I analyse my audio and split the frequencies in 16 'parts'. I store these parts in a message of 16 ints, either 1 or 0 (...
1
vote
1answer
69 views

light leds from an array

I have the project to build a robot for my school. It will record button pushes then move according to this record. Before usig motors, i'm trying to do this using leds. Thanks from posts from this ...
-1
votes
3answers
255 views

How to set an array size to a variable which might change later into the code?

I'm trying to initialize an array globally which could be of different sizes according to future code in Arduino. int n=0; int val[n]; This says that the array bound is not an integer constant before ...

1
2 3 4 5