0% found this document useful (0 votes)
17 views1 page

Efeklampupolisi

Uploaded by

emelkromos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Efeklampupolisi

Uploaded by

emelkromos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <FastLED.

h>

#define NUM_LEDS 48
#define DATA_PIN 6
#define BRIGHTNESS 255

CRGB leds[NUM_LEDS];

void setup() {
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}

void policeLights() {
// Efek lampu polisi merah-biru
for (int i = 0; i < 3; i++) {
// Merah
for (int j = 0; j < NUM_LEDS; j++) {
if (j < NUM_LEDS / 2) {
leds[j] = CRGB::Red;
} else {
leds[j] = CRGB::Black;
}
}
FastLED.show();
delay(100);

// Biru
for (int j = 0; j < NUM_LEDS; j++) {
if (j >= NUM_LEDS / 2) {
leds[j] = CRGB::Blue;
} else {
leds[j] = CRGB::Black;
}
}
FastLED.show();
delay(100);
}

// Efek lampu polisi berkedip


for (int i = 0; i < 5; i++) {
// Semua LED menyala putih
fill_solid(leds, NUM_LEDS, CRGB::White);
FastLED.show();
delay(50);

// Semua LED mati


fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(50);
}
}

void loop() {
policeLights(); // Memanggil fungsi lampu polisi
}

You might also like