Questions tagged [array]

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

Filter by
Sorted by
Tagged with
0
votes
2answers
63 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
37 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
0answers
7 views

Array to remove a number on arduino [migrated]

guys how can I print and remove this number in array? I am trying to do the array but it is not working: i have a if with this number: if (conteudo.substring(1) == "44 46 00 22") so i would like ...
0
votes
2answers
58 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; ...
1
vote
1answer
104 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
54 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
votes
1answer
36 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
62 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 ...
0
votes
1answer
146 views

How to set current position for the DC motor to zero + store current positions in an array and run it?

I would like to know how to set the current position for the DC motors to zero and store the current position in an array. after that I would like it to loop in the array to run all steps that was ...
0
votes
1answer
54 views

Using Arrays and LED's to represent Piano Scales

I am trying to use addressable LED's to show various piano scales using the semi notes formula for each scale as an array and an input to indicate the starting note. int MajorScale[] = {2,2,1,2,2,2,1}...
0
votes
1answer
39 views

Creating an array with the length coming from a library

When creating an array like in the sketch #include <Lib.h> int myArray[Lib::len]; void setup() {} void loop() {} the variable len must be an integer constant that is known at compile time. ...
0
votes
1answer
456 views

Error: invalid application of 'sizeof' to incomplete type 'int []' when trying to compute the size of an array in a library

I have created a library that contains an array. This is the .h file: class Lib { public: static int arr[]; }; And this is the .cpp file: #include "Lib.h" int Lib::arr[] = {0, 1, 2, 3}; ...
0
votes
1answer
24 views

Compute the size of an array that was passed as a parameter to a function

When passing an array to a function, you usually pass the length of the array along with it. You can compute the size of the array with sizeof(myArray)/sizeof(myArray[0]), which works just fine. ...
0
votes
1answer
315 views

Is std::array (from the C++ STL) safe to use on arduino? Does it use dynamic memory allocation?

I'd like to use std::array on a project that will need to be very stable, and have all memory pre-allocated to avoid heap fragmentation. I am reading in characters from the serial port, following a ...
0
votes
2answers
101 views

How to Sort a String with Number by Ascending

I have trouble figuring out how to sort a String that has a Number in it. The String im sending looks like 112:AAAA and 111:EEEE, how would I sort it so that the 111 will be the first in an array but ...
0
votes
1answer
53 views

Expected unqualified-id before 'public'

I'm making an arduino program for a buzzer that you can record notes and song for and then play them back. I have 2 arrays that hold both pitch and if a note is being played. I continue to get errors ...
0
votes
0answers
40 views

memcpy is corrupting serial output even before call

I just want to memcpy some data into a buffer, but it completely destroys my serial output. Arduino Nano Arduino IDE || VS Code with Platform.io Here the relevant declarations: uint8_t picture[4170]...
0
votes
0answers
75 views

Reading from SD and save it in an array

I have a text file with an IR raw code that I need to read from the SD in order to send it and I don't know how to do it. I tried to use the read file function from the specific SD library but it didn'...
0
votes
1answer
71 views

typedef function pointer array declaration problem

Thanks for all your feedback. It helped. I rewrote this yet another time and this time it works perfectly. I included three variations: a simple example using an array of function pointers, a Lambda ...
0
votes
1answer
275 views

How to scale a bitmap (uint8_t array) in Arduino?

So I have a project where I send text to an Arduino, which is then printed out as a QR code on a thermal printer that can take a bitmap image with a given width and height. Is there a way I can "...
0
votes
0answers
124 views

Fail to obtain Sizeof Array

I have a nested array, but I get only the correct size of the first one. I use this as a reference Arduino sizeOf int clockOn_0 [] = {19,0,0}; int clockOn_1 [] = {20,0,0}; int clockOff_0[] = {6,0,0}...
0
votes
1answer
242 views

How to return Char Array Value in Arduino IDE Function?

Function char* getConnectDetail(int starting){ String data; for(int i=0;i< 1024 ;i++) { if(EEPROM.read(i+starting) != 0){ data += char(EEPROM.read(i+starting)); } } int ...
1
vote
1answer
144 views

Merge two 8 bit arrays to one 16 bit array

I am an absolute newbie to Arduino and C++ and try to go through some tutorials to gain a minimal insight. However I stuck already at some tiny Points. What I want to do? Merge two 8 bit integer ...
1
vote
1answer
495 views

Cannot convert 'int (*)[size]' to 'int**' [closed]

Analyzing this and this answers under Arduino, which should be the proper way to pass a 2D array into a function? The function should be applicable to different sizes of 2D arrays. // NOT COMPILING ...
1
vote
1answer
35 views

Serial Port fails with speeds greater than 19200

In Arduino Mega 2560 R3, properly selecting the Serial Monitor bauds, this code works with #define R 38400, but for some reason, not with #define R 19200 (?), #define R 38400 int rate=R; ...
1
vote
1answer
71 views

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 ...
0
votes
1answer
66 views

HardwareSerial Indexing Array

How should I index HardwareSerial ports into a single array?. This compiles, but do not work. HardwareSerial Serials[]={Serial,Serial1,Serial2,Serial3}; void setup(){ for (int i=0;i<=3;i++){ ...
1
vote
1answer
184 views

USing arrays, binary data and bitRead

This is my first manually typed code. I'm sure there may be some glaring "schoolboy errors" in it, so wondered if people could give it the 'once over' In particular, I have never used C++ arrays, ...
0
votes
1answer
490 views

How to programme a button per colour for a neopixel strip?

I am trying to make a particular pixel in a neopixel strip, turn green, red or blue depending which button has been pressed and to stay on until pressed off again (like a toggle), but currently when I ...
2
votes
2answers
444 views

Why does a variable size struct not compile in the Arduino IDE?

This sketch does not compile in the Arduino IDE void setup() { // put your setup code here, to run once: } struct test { int i; char variable[]; }; typedef struct test test; test t = { 0, ...
0
votes
0answers
43 views

problem with char array iteration and strcmp

New to Arduino and programming so forgive me if this is trivial but I've searched and can't find an answer... Goal: I want to convert decimal values to their equivalent fraction... eg: 0.125=1/8. I ...
0
votes
2answers
96 views

How to increase the serial port's data throughput

I have an array of numbers that will be subtracted from the ADC readings of a 50 Hz sine wave. Using Serial.begin(57600);, I can only output 25 samples per sine wave cycle, or about 1,250 samples ...
1
vote
1answer
24 views

Is new.cpp programmed improperly? Arduino 1.8.9

I'm having trouble with my code and I'm not sure if it's a memory allocation issue. So I look at the new, delete to see if it throws errors, and finding the source code I find outrageously simple ...
0
votes
0answers
155 views

sending array of data using spi

am using two arduino uno to start communicating using spi by sending an array of data but actually I having a trouble because the master is only showing me the first byte of the slave's array however ...
0
votes
1answer
54 views

Can't store RFID data in the next 5 bytes of array

I'm working on RFID project to handle multiple cards. I did most of the things OK. But now I have one problem. Which is the following: The RFID code is 5 bytes, so I need an array of 5 bytes. If ...
0
votes
2answers
62 views

Reading Digital Pins and Outputing on entire Ports

I'm very new to coding so please don't grill me. I'm working on a scientific project where I am using a NI-DAQ to digitally trigger mosfets to trigger 300us - 3ms pulses on two high powered LED ...
0
votes
1answer
83 views

Parsing array of an object in a library constructor

I am trying to develop an Arduino library that consists out of two classes. I want 'WayPointStack' to store an array of 'WPCommand', but I can't get it to work. WayPointStack.h #ifndef ...
1
vote
1answer
532 views

Passing arrays, global arrays within functions, pointers, and declaring array sizes

I'm super confused right about now! I've been working on project involving Xbees in API mode, and I need to send different arrays of bytes to the Xbee depending on which buttons I press. Mostly what ...
0
votes
0answers
95 views

How to put the inputs in array?

I face a problem and I really need help. For my Arduino project, I'm using RFID reader with tags. The story is, I have a desired arrangement for the cards and I defined it as an array called desired[]=...
0
votes
0answers
54 views

Problem: char string not working with SoftwareSerial.h

I am creating a program to display text on an OLED display and then have it sent to a thermal printer. The issue is my second char string: word_buffer When I try to use word_buffer for any reason it ...
0
votes
1answer
106 views

Specific formatting of floats and converting them to an array of chars

I have an oled display which can only display 4 digits + decimal point. I need a way to format the number into 4 significant figures; Then I need to convert that into an array of 5 chars (4 digits and ...
0
votes
1answer
50 views

How to convert a delimited string of hex numbers to an int array

I am sending a string to the Arduino via serial, I made the program that sends the data, so I can change it to anything, but for now it sends a string of hex numbers delimited by ':', so for example ...
1
vote
2answers
202 views

Creating an array of structures which store bitmaps to work with u8glib

I've tried reading the documentations and I'm getting desperate because I can't find anything. I need to create an array of structures, which contains a bitmap stored in PROGMEM space (because of ...
1
vote
1answer
2k views

Length of uint8_t* const array

I've an array of type uint8_t* const with 6 items, defined like this uint8_t* const neighbourSet[] = {PEER1, PEER2, PEER3, PEER4, PEER5, PEER6}; Whereas each element in this array is static uint8_t ...
0
votes
0answers
169 views

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 ...
1
vote
1answer
577 views

Does Arduino C++ support dynamic arrays of objects

My C++ is seriously out-of-date, and I'm working on a project that will be juggling multiple timed actions at the same time, with a menu system to manage the interface and control those timed actions (...
1
vote
1answer
51 views

Dynamic allocation/ Pointer to Pointer to update an Array containing parameter [closed]

topicArray defined as follows: const char* msgTopic = "Home/Messages"; const char* groupTopic = "Home/All"; char* deviceName = deviceTopic; const char* topicArry[2] = {deviceTopic, groupTopic}; But ...
0
votes
0answers
124 views

How to store an array of doubles? As array of doubles, Strings or const char *? Then convert back to use?

This seems like an old, solved problem, but I can't find any simple answers. I'm reading latitude and longitude data as Strings from a file (about 50 points), but they are really double float numbers. ...
0
votes
1answer
55 views

Message Interpreter and Handler - How to store a function name in a struct?

For a project, I need to store an array of structures in PROGMEM. Array MessageTable[] will be composed of about ten struct InMessage elements. InMessage looks sort of like this: struct AvcInMessage {...
0
votes
1answer
53 views

Stacks on arrays on arrays

I am trying to find a "vanilla" way of writing several arrays into one. I spent a lot of time searching for how to do this but everything that comes up is either a tutorial that doesn't cover ...

1
2 3 4 5