Обновление Arduino
This commit is contained in:
73
code/Arduino/memory/variables_sizes.ino
Normal file
73
code/Arduino/memory/variables_sizes.ino
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Скетч, который выводит в Serial размер типов переменных в байтах
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
size_t size_variable;
|
||||
|
||||
int example_int;
|
||||
unsigned int example_uint;
|
||||
signed int example_sint;
|
||||
unsigned long example_ulint;
|
||||
float example_float;
|
||||
double example_double;
|
||||
char example_char;
|
||||
char * example_string;
|
||||
bool example_bool;
|
||||
|
||||
size_variable = sizeof(example_int);
|
||||
Serial.print("int bytes size: " );
|
||||
Serial.println(size_variable);
|
||||
|
||||
size_variable = sizeof(example_uint);
|
||||
Serial.print("unsigned int bytes size: " );
|
||||
Serial.println(size_variable);
|
||||
|
||||
size_variable = sizeof(example_sint);
|
||||
Serial.print("signed int bytes size: " );
|
||||
Serial.println(size_variable);
|
||||
|
||||
size_variable = sizeof(example_ulint);
|
||||
Serial.print("unsigned long bytes size: " );
|
||||
Serial.println(size_variable);
|
||||
|
||||
size_variable = sizeof(example_float);
|
||||
Serial.print("float bytes size: " );
|
||||
Serial.println(size_variable);
|
||||
|
||||
size_variable = sizeof(example_double);
|
||||
Serial.print("double bytes size: " );
|
||||
Serial.println(size_variable);
|
||||
|
||||
size_variable = sizeof(example_char);
|
||||
Serial.print("char bytes size: " );
|
||||
Serial.println(size_variable);
|
||||
|
||||
size_variable = sizeof(example_string);
|
||||
Serial.print("char * bytes size: " );
|
||||
Serial.println(size_variable);
|
||||
|
||||
size_variable = sizeof(example_bool);
|
||||
Serial.print("bool bytes size: " );
|
||||
Serial.println(size_variable);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Arduino Nano
|
||||
*
|
||||
* int bytes size: 2
|
||||
* unsigned int bytes size: 2
|
||||
* signed int bytes size: 2
|
||||
* unsigned long bytes size: 4
|
||||
* float bytes size: 4
|
||||
* double bytes size: 4
|
||||
* char bytes size: 1
|
||||
* char * bytes size: 2
|
||||
* bool bytes size: 1
|
||||
*/
|
||||
Reference in New Issue
Block a user