Hardware Setup:

  • LED Matrix: 8x8 LED matrix with MAX7219 controller (the common 16-pin module)
  • Connections:
    • VCC → 5V
const int trigPin = 9;
const int echoPin = 10;
const int redPin = 3;
const int greenPin = 5;
const int bluePin = 6;

void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void loop() {
  float distance = getDistance();
  setColorByDistance(distance);
  
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  
  delay(200);
}

float getDistance() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite

RGB LED Features:

  • Smooth color transitions from red → yellow → green → blue based on distance
  • Blinking red alert for objects closer than threshold
  • Color-coded distance ranges with adjustable thresholds

⚡ Electrical Resistance Tutorial

Understanding Ohm's Law and Resistor Color Codes

What is Electrical Resistance?

Electrical resistance is the opposition to the flow of electric current through a material. Think of it like water flowing through a pipe - a narrow pipe offers more resistance than a wide one. Resistance is measured in Ohms (Ω).

V = I × R

Voltage = Current × Resistance