/*-data-type------size---------description----------------------
boolean (8 bit) - [true/false]
byte (8 bit) - [0-255] unsigned number
char (8 bit) - [-128 to 127] signed number
unsigned char (8 bit) - [-128 to 127] signed number
word (16 bit) - [0-65535] unsigned number
unsigned int (16 bit) - [0-65535] unsigned number
int (16 bit) - [-32768 to 32767] signed number
unsigned long (32 bit) - [0-4,294,967,295] unsigned number usually for millis
long (32 bit) - [-2,147,483,648 to 2,147,483,647] signed number
float (32 bit) - [-3.4028235E38 to 3.4028235E38] signed number
uint8_t (8 bit) - [0-255] unsigned number
int8_t (8 bit) - [-127 - 127] signed number
uint16_t (16 bit) - [0-65,535] unsigned number
int16_t (16 bit) - [-32,768 - 32,767] signed number
uint32_t (32 bit) - [0-4,294,967,295] unsigned number
int32_t (32 bit) - [-2,147,483,648 - 2,147,483,647] signed number
uint64_t (64 bit) - [0-18,446,744,073,709,551,615] unsigned number
int64_t (64 bit) - [−9,223,372,036,854,775,808 - 9,223,372,036,854,775,807] signed number
--------------------------------------------------------------
camelCase - anything that changes
snake_case - variable's that are exclusive in a function
Snake_Case - CLASS/struct exclusave varables/functions
iNVERTEDcAMELcASE - outside code that is being accessed [database]
SNake_CAse - duplicate varables inside the case function [frequently used in library names]
ALL_CAPS - const varable names or defines
------------- by jediRick & RefreshMyMind --------------------
*/
#define ledPin LED_BUILTIN
word delayTime = 10;
word delayTimeUsed = delayTime / 2;
unsigned long startTime;
unsigned long endTime;
unsigned long resultingTime;
unsigned long resultingTime2;
uint16_t iterations = 200;
void setup() {
delay(2000);
Serial.begin(115200);
Serial.println("Speed-test by JediRick");
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
Serial.println("Starting test!");
makeNumber();
Serial.println("Test Complete!");
resultingTime = endTime - startTime;
Serial.println("Time in micros: " + (String)resultingTime);
resultingTime2 = 1000000 / resultingTime;
Serial.println("cycles per second: " + (String)resultingTime2);
delay(5000);
}
void makeNumber() {
uint32_t numCount1 = 1;
uint32_t numCount2 = 1;
uint32_t numCount3;
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
startTime = micros();
for (uint16_t i = 0; i < iterations; i++) {
numCount3 = numCount1 + numCount2;
numCount1 = numCount2;
numCount2 = numCount3;
}
endTime = micros();
digitalWrite(LED_BUILTIN, LOW);
Serial.println("Fibonacci cycle count: " + (String)iterations);
Serial.println("Result: " + (String)numCount3);
}