/*
ESP32 Data Types Demo
Demonstrates: int, char, float, boolean, String, and arrays
*/
// Constants
#define LED_PIN 2 // Built-in LED pin
const float pi = 3.14159;
// Global Variables
int counter = 10; // Integer
float voltage = 3.3; // Float (decimal)
boolean isActive = true;// Boolean (true/false)
char grade = 'A'; // Single character
String message = "Hello from ESP32"; // String
// Arrays
int numbers[3] = {10, 20, 30}; // Integer array
String colors[4] = {"Red", "Green", "Blue", "Yellow"}; // String array
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
// Print all variables
Serial.println("=== Basic Data Types ===");
Serial.println("Integer: " + String(counter));
Serial.println("Float: " + String(voltage));
Serial.println("Boolean: " + String(isActive));
Serial.println("Character: " + String(grade));
Serial.println("String: " + message);
Serial.println("Constant PI: " + String(pi, 4)); // 4 decimal places
// Control LED with boolean
digitalWrite(LED_PIN, isActive);
// Demonstrate array access
Serial.println("\n=== Array Examples ===");
Serial.println("First number: " + String(numbers[0]));
Serial.println("Third color: " + colors[2]);
// Modify values
counter = 100;
voltage = 5.0 / 2.0; // Results in 2.5
isActive = false;
Serial.println("\n=== Modified Values ===");
Serial.println("New Integer: " + String(counter));
Serial.println("New Float: " + String(voltage));
Serial.println("New Boolean: " + String(isActive));
}
void loop() {
// Empty (example runs once)
}