Group Nguyen Krajewski others
Group members
- Khai Nguyen
- Hoang Bach Nguyen
- Ly Thai Hoa
- Miglio Krajewski
NeoPixel Programming and Power Measurement
Programming the NeoPixel
The program controls the LEDs and allows different lighting conditions to be tested while measuring electrical power.
Key Elements of the Code

The program uses the Adafruit NeoPixel library to control the LED ring. The following headings will explain the code.
Constant Definitions
#define PIN 9
Creates a constant referencing PIN9. Constants cannot be changed throughout the code. A constant is suitable in this case, as the PIN with the signal output for the Neopixel will not change (unless desired, requiring physical restructuring).
#define NUMPIXELS 24
Creates a constant for the number of Neopixel LEDs in series, suitable as this is a property of the neopixel array used.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Creates an instance, pixels, of the Adafruit_NeoPixel class, assigning the object the constants PIN and NUMPIXELS.
Parameters used:
-
NUMPIXELS – number of LEDs
-
PIN – data pin used for communication
-
NEO_GRB + NEO_KHZ800 – LED color order and communication speed
int delayval = x
Defines the delay time x between operations in the loop.
This delay controls how quickly the LEDs change state.
pixels.xxxx()
Calls methods (functions) of the Adafruit_NeoPixel class for the pixel object.
For example, pixels.setPixelColor() is used in the loop to pass the colour onto the pixel object.
Changes that were made during the power consumption test include:
- Adding an int variable that uses “NUMPIXELS” to calculate a desired neopixel sequence length and replacing “NUMPIXELS” in the for-loop.
- Removing pixels.clear() to stop blinking
- Changing delayval to alter the frequency of the blinking
Measuring Electrical Power
P=U×I
To evaluate the power consumption of the NeoPixel ring, voltage and current were measured under different lighting conditions.
The electrical power was calculated using the famous formula: P=U×I
Where:
P = Power (Watts)
U = Voltage (Volts)
I = Current (Amperes)
Case 1 – No LEDs Turned On

When the NeoPixel ring is connected but no LEDs are lit:

Measured values:
Voltage: 5.18 V, current: 0.07 A
Calculation:
𝑃 = 5.18 × 0.07 = 0.3626 W
Case 2 – Half of the LEDs Turned On

When half of the LEDs in the ring are illuminated:

Measured values are: Voltage: 5.13 V, Current: 0.23 A
So, electrical power is 1.179 W.
Observations
From the measurements we can observe:
Power consumption changes depending on the number of LEDs that are active.
The NeoPixel ring requires a stable 5V supply, can be plugged from the pins.
Measuring both voltage and current allows the real power usage of the LEDs to be calculated.