SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By brianuno
#193799
At the end of the beginner's tutorial series is a postscript "Going Further" introduction to data types, link below. With only an Arduino board, the sketch written for the topic, and the serial monitor, you can do arithmetic, in other words, a calculator. Once uploaded, you can change values for x and y in this block of code and see the desired sum on the serial monitor:
Code: Select all
#define test_type byte
test_type x = 1;
test_type y = 2;
test_type z = 3;
The main lesson here is calling out data types correctly in a sketch. For instance, in this block of code, byte can be changed to boolean, char, int, float, and others, for various reasons I can't go into here. Larger number data types take longer to process, and increase the total compile size. Not important in simple sketches, but some of the sketches I have looked at are long enough for it to matter. See Robot Travel In Straight Line, Tuesday Feb 21, 2017 1:45 pm from this forum. There are too many useful lessons to be learned from this simple experiment for one post. Anybody know the writer, b_e_n? Props!
https://learn.sparkfun.com/tutorials/da ... in-arduino