// 2009 mlab.uiah.fi/paja // Understanding variable types // Scope of data types // 1 bit stores 1 and 0. // 2 bits store from 0 to 4. if it's signed, it stores from -2 to 2. // 8 bits is 1 byte which stores 0 to 255. if it's unsigned, it stores from -127 to 127. int myInt = 32767; // Integer data type takes up 2 bytes (-32,768 to 32,767) unsigned int myUnint = 65535; // Unsigned integer also takes up 3 byts but it it stores only positive number from 0 to 65,535 long myLong = 2147483647; // Long takes up 4 bytes (-2,147,483,648 to 2,147,483,647) unsigned long myUnlong = 4294967295; void setup() { Serial.begin(9600); } void loop() { Serial.println("*** Print all variables"); Serial.print("myInt: "); Serial.println(myInt); Serial.print("myUnint: "); Serial.println(myUnint); Serial.print("myLong: "); Serial.println(myLong); Serial.print("myUnong: "); Serial.print(myUnlong); Serial.println(); Serial.println("*** Add 1 to all variables"); Serial.print("myInt: "); Serial.println(myInt +1); Serial.print("myUnint: "); Serial.println(myUnint +1); Serial.print("myLong: "); Serial.println(myLong +1); Serial.print("myUnong: "); Serial.print(myUnlong +1); Serial.println(); delay(3000); }