Why does setting the LED LOW make it come on?

Hello everyone, I downloaded this code for a air particulate sensor. I'm curious why setting the LED to LOW turns it on in this sketch. Does it have to do with the common cathode, common anode thing? Thanks

//pressing nothing to display value of analog revolving potentiometer
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

int measurePin = 0; //Connect dust sensor to Arduino A0 pin
int ledPower = 2;   //Connect 3 led driver pins of dust sensor to Arduino D2
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;

void setup(){
  lcd.init();                      // initialize the lcd 
  lcd.init();                      // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Raw Signal Value: ");
  lcd.setCursor(0,2);
  lcd.print("Voltage:");
  lcd.setCursor(0,3);
  lcd.print("Dust Density:");
  pinMode(ledPower,OUTPUT);
}

void loop(){
  digitalWrite(ledPower,LOW); // power on the LED
  delayMicroseconds(samplingTime);
  voMeasured = analogRead(measurePin); // read the dust value
  delayMicroseconds(deltaTime);
  digitalWrite(ledPower,HIGH); // turn the LED off
  delayMicroseconds(sleepTime);
  // 0 - 5V mapped to 0 - 1023 integer values
  // recover voltage
  calcVoltage = voMeasured * (5.0 / 1024.0);
  // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
  // Chris Nafis (c) 2012
  dustDensity = 0.17 * calcVoltage - 0.1;
  lcd.setCursor(1,1);
  lcd.print(voMeasured);
  lcd.setCursor(9,2);
  lcd.print(calcVoltage);
  lcd.setCursor(14,3);
  lcd.print(dustDensity);
  delay(1000);
}

I'm curious why setting the LED to LOW turns it on in this sketch.

Because it causes current to flow.

An LED lights when current flows through it. One end of the LED must be connected to the positive supply and one end to GND. Your LED must have the GND end (the cathode) connected the the Arduino I/O pin and the other end (the anode) connected to the positive supply.

...R

I ran into this when I was using LED traffic signals for my model railroad.
I am sure that Robin2's description above is accurate.
I just noticed that when I turned the Green light on in code, and the Red and Yellow lights off, instead the Green was the only one off.
I swapped the logic for turning on and off each light and got the desired results.

Thanks everyone!

I'm trying to understand the point of "sleepTime". Is this to give the sensor enough time to display a readying without it bouncing between values too rapidly?

Bluenick2100:
I'm trying to understand the point of "sleepTime". Is this to give the sensor enough time to display a readying without it bouncing between values too rapidly?

You would have to consult the documentation for the air particulate sensor and understand it, to answer this question.

Thanks