Questions tagged [data-type]

Identifies the size and nature of information held by a variable in a program. It is language-dependent. Examples for C/C++ include: `int`, `float`, and `char`.

Filter by
Sorted by
Tagged with
1
vote
2answers
57 views

Comparing custom variable type definitions

In a library I am using with an OBD adapter, they define a public function to get the state of the OBD connection using some strange (and, in my opinion, useless) custom defined variable type: // ...
0
votes
3answers
14k views

How can i get rid of the error “cannot convert 'String' to 'const char*'”

I want to get this code to recognise different commands and be able to parse the rest of the command, fore example I send "/sleep 5", and it will sleep for 5 seconds. However, I keep on getting this ...
1
vote
1answer
141 views

DS18B20 sending variable via Enthernet shield

I am trying to send temperature read from DS18B20 to a web server. I know two things: to read a temperature, and to send something to web server. What I don't know is how to convert float that ...
1
vote
1answer
5k views

Put integer and double into char array

I want to print text and numbers mixed in a table with Serial.print(); from a char array. My problem is the conversion between the different data types. My idea is to print the data of the rows in a ...
0
votes
1answer
755 views

Store values in array

I'm trying to implement the "BNO055 9 Axes Motion Shield". There is an existing Arduino sketch GitHub that reads out the Euler data, I changed it a bit to print out quaternion data. #include "...
0
votes
2answers
7k views

Converting (char*)variable to int

I have the following code: uint8_t buf[1]; uint8_t buflen = 1; if (driver.recv(buf, &buflen)) // Non-blocking { int i; // Message with a good ...
0
votes
1answer
2k views

RF receiver for integer only, how to cast uint8_t to int?

I'm using the RadioHead library with ASK Driver to transmit/receive data with generic RF modules. It works fine, but I'm lacking some knowledge in programming the code to use the data received. Most ...
1
vote
2answers
1k views

How can I write an integer to a Mifare RFID card using the RFID library?

I'm a beginner to C++ and I'm clearly missing some fundamental knowledge of data types. As such, I'm struggling to adapt the examples in the miguelbalboa/rfid library to my use case. I'm simply trying ...
0
votes
1answer
6k views

Receiving hex data from terminal [closed]

I am trying to transmit serial data from terminal to Arduino and I want to reconfirm that its the same data. But I am not able to get the right answer. I want data to be HEX. I want to check only the ...
1
vote
2answers
2k views

Const data optimisation for Arduino

I'm taking a course on Arduino Uno programming and on today's talk I heard that the const data is optimized by Arduino, so that it occupies less space than the actual data type (namely, a const int ...
1
vote
3answers
3k views

Why char 0x80 == 0xFFFFFF80?

As far as I know a char is an 8 bit variable void setup() { Serial.begin(9600); } void loop() { char x = 0x80; if(x != 0x80){ Serial.println(x, HEX); } delay(1000); }
1
vote
2answers
2k views

Unable to compare two integer values in Arduino Mega

I wrote Arduino code (code is given at the end) to compare two integer values. The steps I took was: Give input to DC motor to rotate it using serial port. Input was: G254 Then I store it in XX ...
0
votes
1answer
5k views

String to unsigned long conversion

I'm trying to use strtoul() to convert an Arduino String to an unsigned long (like the return of millis();) using the following code snippet: unsigned long foo (String time) { unsigned long mili; ...
0
votes
1answer
5k views

What is causing this 'narrowing conversion' warning?

Because I'm still figuring out 'Arduino C' I leave all warnings on. Recently I got this one: narrowing conversion of '(int)(((unsigned char)bx_0) | ((unsigned char)bx_1))' from 'int' to 'const byte.....
0
votes
2answers
167 views

Arithmetic types in Arduino

I'm looking for a complete list of the arithmetic types in the Arduino framework. On the Internet I found various incomplete lists: sometimes there is short, sometimes word, but other types are ...
2
votes
1answer
137 views

Determine whether a variable is of an arithmetic type

Is there a way to determine whether a variable is of an arithmetic type or not? arithmetic: integer, floating point numbers, boolean values not arithmetic: pointers, references; e.g. strings, and ...
1
vote
2answers
253 views

Is this assignment valid or needs casting?

I have this assignment and while i don't get any error not even warning from the compiler. uint16_t Buffer[40000]; for (int n=0; n<40000 ; n++){ Buffer[n] = (0.99 * cos(((2.0*PI)/40000)*n); } ...
3
votes
2answers
4k views

inttypes vs Arduino defined integral types

In my Arduino projects I use both Arduino types and types defined in the "inttypes.h" file, which #includes stdint.h. So far I've always written code only for the ATmega328P microcontroller (either in ...
0
votes
2answers
110 views

character input for an integer variable? [duplicate]

Im trying out the code found here , let me quote the section of code that bothers me. // set pin numbers for switch, joystick axes, and LED: const int switchPin = 2; // switch to turn on and off ...
0
votes
1answer
506 views

What datatype is the names of the analog inputs?

I am writing a code for an automatic garden, and for this, I will use an array of sensors. I want to represent each plant as a class, and so one of the private variables will then be the sensorID, the ...
8
votes
4answers
45k views

Convert to and from Unix Timestamp

What is the best way to convert between date, hours, min, seconds to Unix timestamp in milliseconds in Arduino? I need to have this conversion, since I'm using RTC (date, hours, min, secs etc) and ...
0
votes
2answers
163 views

Testing ID and Serial Communication (Update)

Here is my challenge: I have to create a sketch where I would have a prompt asking the user to enter an ID. If it is successful, it would turn on the green LED and response with "Hello, your name is ...
0
votes
2answers
1k views

Having problems with I2C - Slave is receiving “b ~ ,,,”

so I'm facing a pretty large problem. I'm experimenting with I2C and using one Arduino that acts as a countdown timer to send the current reading on the timer to another Arduino. I'm pretty new to ...
0
votes
1answer
147 views

Understanding SevSeg

I need to write a library for a display I created with eight segments. So, I decided to try to use SevSeg (https://github.com/DeanIsMe/SevSeg) as a starting off point. It can't be that different, ...
1
vote
3answers
819 views

How is a local variable address retrieved/returned inside the CPU of Arduino?

How is the address of a local variable retrieved in Arduino's ATMEGA328 micro-controller? Lets say somewhere inside the main we have lines as: int x = 5; //a variable declared and value of 5 stored ...
2
votes
2answers
140 views

How does an 8bit MCU make use of data-types over 8bits?

how does an 8bit MCU handle 16bit output? How does an 8bit MCU store values higher than 8bits? I am using an attiny, on an adafruit trinket. and other 8bit MCUs. http://www.atmel.com/devices/attiny85....
0
votes
1answer
442 views

What is the datatype of the pinMode function?

I just tried it, but the Arduino IDE crashed, I hope its not related. I want to declare a datatype like this: int a = pinMode(pin, OUTPUT); or something like that, but I'm not sure what datatype the ...
-2
votes
3answers
4k views

What Arduino data type allows decimals?

This probably sounds dumb, but I am not getting any clear answer for this. What data type allows a reasonable amount of decimals?
2
votes
2answers
2k views

Writing a float to a BLE characteristic. What data format?

I am currently working on a python-based Bluetooth Low Energy client for OS X and I got stuck while trying to write a remote float characteristic value. First of all: my setup is an Arduino 101 with ...
2
votes
2answers
199 views

How can i do something like multi threathing in arduino?

I am checking for ways to implement multi threathing in Arduino, I have also tried using the library TimerOne but it doesn't seem to work, what I'm trying to make is an Arduino application then, every ...
1
vote
1answer
3k views

What does 16u and 128u mean?

The below is a snippet of a code for operating SI4455 Rf module with Arduino. I have some doubts which I'd like to seek some help in clearing. byte numOfBytes = *pSetPropCmd++; if (numOfBytes &...
-1
votes
2answers
201 views

how to use an object of a class within that same class? [duplicate]

I want to write a tree data structure made up of Nodes, but I'm having a problem with my Node.h class as each Node need to have a reference Variable to other Nodes,it's children. which ends up giving ...
0
votes
1answer
636 views

Getting RGB values from camera

I have a camera I'm planning on attaching to an arduino uno, that I want to take pictures and extract the average RGB value from each image. This is the camera I have, but I've now realized that it ...
0
votes
1answer
5k views

error: invalid conversion from 'char' to 'char*' [-fpermissive]

I have written a simple code to read data from capacitive keypad and display it on LCD. I am getting the data from keypad in following data structure. char phoneNumber[PHONE_DIGITS]; and then ...
1
vote
0answers
86 views

incoming GSM data stored as variable in code [closed]

I am using an Arduino Mega board with a SIM900 GSM. My goal is to be able to text the GSM with a value of two digits (ex: 79) and then store that value as a variable in the code. I know how to set ...
0
votes
2answers
6k views

Convert uint8_t array to ascii character for serial transmission

I am trying to send packets of via bluetooth data that include 6 bytes read from a sensor and stored in a uint8_t array. Instead of sending over the data as numerical digital, I would like to send the ...
1
vote
0answers
339 views

How to get Type name of a variable on Arduino [duplicate]

I found this post and implemented the code in a separate classed and then passed different variables to it in an attempt to get the type name printed to serial. The code compiled and worked fine but ...
0
votes
3answers
2k views

A library for manipulate Intel Hex data?

For a project i need to extract some data from an external eeprom and then store it somewhere. Suddenly after some manipulations (not necessarly with Arduino board) i need to put them in an external ...
0
votes
2answers
73 views

How to properly process large arithmetic

just a question that requires a simple answer. How do I process a large number of arithmetic steps in arduino efficiently and precisely? For example I have this code function setup: void calc() { ...
0
votes
1answer
115 views

Simple Arduino Serial Arithmetic

I'm developing a program to calculate static margin of an aircraft through the calculations of mass,moment and arm. Essentially dealing with large numbers. I'm having difficulty in setting up my code ...
2
votes
2answers
5k views

Since double and float represent the same data type (usually), which is preferable?

It looks like on ATMega based boards, float and double are equivalent 32-bit (4-byte) data types. However, on the Arduino Due, doubles are 64-bit (8-byte) where floats are 32-bit (4-byte), same as ...
0
votes
4answers
4k views

Multiplication, division. What is wrong?

const unsigned long C1 = 30 * 1000; const unsigned long C2 = (300 * 1000)/C1; // must be = 10 void setup() { Serial.begin(57600); Serial.println("\n-------"); Serial.print("C1 = "); Serial....
3
votes
5answers
6k views

Serial.print() is slower than it should be

I'm trying to use Arduino as a DAQ but the Serial.print() is not working as fast as I expected. How many bits are sent if you are using a int, because if I use a uint8_t, it's taking the same amount ...
1
vote
1answer
2k views

Trouble with large numbers

Probably something stupid, but I can't figure out how to work with these large numbers, then cast the result (which will be small) to an integer. I keep getting negative numbers, which I think means I'...
1
vote
2answers
2k views

invalid conversion from 'char' to 'const char*'

My intention was to overload a function to handle optional parameters. My code looks like void functionA(const char *errorMsg) { functionA('0', errorMsg); } void functionA(char errorCode, const ...
2
votes
2answers
3k views

Arduino Variable Data Type?

Is there a variable data type available for Arduino? I have a class that should have a member that will differ in data type, in the past I have used the "variable" keyword in c++ but when I tried to ...
2
votes
4answers
4k views

Assemble or typecast byte array to float

The serial port on my Arduino Mega is receiving 3 floats as bytes (total of 12 bytes, 4 per float) over serial. Unfortunately I cannot assemble the 4 Bytes in a float, as the serial monitor only ...
1
vote
1answer
2k views

Cast from long to int

How does arduino uno cast from long to int? Does it truncate the bits? (Does it just delete the 16 most left bits?)
1
vote
1answer
2k views

Using union to return a range of bits from a data frame: wrong approach?

I'm working on an adaptation of Jason Leyrer's Guitar Hero Library for Arduino. My version is for a DJ Hero controller, and I've also borrowed some code from this Arduino forum thread: topic=120527 (...
0
votes
3answers
2k views

Having issues with Arduino + Bluetooth

I am working with a combination of Teensy++ 2.0 and Sparkfun Bluetooth Modem. The Arduino program, inside the loop, continuously reads a sensor value. If the value read is above a threshold, the ...