// Chilonzor tablo massa
// #include <FastLED.h>
// #define buttonOldinga 4
// #define buttonOrqaga 5
// #define LED_PIN 13
// #define NUM_LED 17
// int button_pressed_count = 0;
// int button_state = 0;
// int prev_button_state = 0;
// long interval=500;
// long previousMillis=0;
// CRGB leds[NUM_LED];
// void setup() {
// Serial.begin(9600);
// pinMode(buttonOldinga, INPUT_PULLUP);
// FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LED);
// Serial.println("Button count");
// }
// void offAllLeds(){
// for(int i=0; i<17; i++){
// leds[i] = CRGB(0,0,0);
// }
// }
// void onLed(int led){
// for(int i=0; i<17; i++){
// if(led == i){
// leds[i] = CRGB::Green;
// }
// }
// }
// void onAllLeds(){
// for(int i=0; i<17; i++){
// leds[i] = CRGB(255,255,255);
// }
// }
// void loop() {
// button_state = digitalRead(buttonOldinga);
// if(button_state != prev_button_state){
// if(button_state == HIGH ){
// digitalWrite(13, LOW);
// }else{
// digitalWrite(13, HIGH);
// button_pressed_count++;
// Serial.println(button_pressed_count);
// }
// delay(50);
// }
// prev_button_state = button_state;
// if(button_pressed_count%32==0){
// offAllLeds();
// }
// if(button_pressed_count%64==0){
// onLed(0);
// }else if(button_pressed_count%32==0){
// onLed(17);
// }
// if(int (button_pressed_count/32)%2==1){
// onLed(16-int((button_pressed_count%32)/2));
// }else{
// onLed(int((button_pressed_count%32)/2));
// }
// // if((buttonPin)==HIGH){
// // button_pressed_count+=1;
// // delay(500);
// // }
// if(button_pressed_count%2==1){
// unsigned long currentMillis=millis();
// if(currentMillis - previousMillis > interval){
// previousMillis=currentMillis;
// int curred_led;
// if(button_pressed_count%64>32){
// curred_led=16-int(button_pressed_count%32/2)-1;
// }else{
// curred_led=int(button_pressed_count%32/2)+1;
// }
// if(leds[curred_led]==HIGH || leds[curred_led]==LOW){
// leds[curred_led] = CRGB::Red;
// }else{
// leds[curred_led] = CRGB(0,0,0);
// }
// }
// }
// FastLED.show();
// // delay(100);
// }
// Yunusobod tablo massa
// #include <FastLED.h>
// int buttonKalla = 4; // kalla uchun 4-knopka
// int buttonDum = 5; // dum uchun 7-knopka
// int buttonOrqagaKalla = 7; // kalla orqaga qaytish uchun 5-knopka
// int buttonOrqagaDum = 6; // dum orqaga qaytish uchun 5-knopka
// #define LED_PIN 13 // led pin 13
// #define NUM_LEDS 8 // ledlar soni
// // kalla
// int button_pressed_count = 1; // kalla
// int button_state_kalla = 0; // kalla
// int kalla_button_state = 0; // kalla
// // dum
// int button_pressed_count_dum = 17;
// int button_state_dum = 0; // dum
// int dum_button_state = 0; // dum
// // kalla orqaga qaytish
// int button_stateorqa_kalla = 0;
// int orqa_button_state_kalla = 0;
// // dum orqaga qaytish
// int button_stateorqa_dum = 0;
// int orqa_button_state_dum = 0;
// long interval = 500;
// long previousMillis = 0;
// CRGB leds[NUM_LEDS];
// void setup() {
// Serial.begin(9600); // monitorda tekshirish
// pinMode(buttonKalla, INPUT_PULLUP);
// pinMode(buttonDum, INPUT_PULLUP);
// pinMode(buttonOrqagaKalla, INPUT_PULLUP);
// pinMode(buttonOrqagaDum, INPUT_PULLUP);
// FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
// Serial.println("Button count"); // monitorda tekshirish
// fadeEffect(); // arduino yonganda reklama
// }
// void offAllLeds() {
// for (int i = 0; i < NUM_LEDS; i++) {
// leds[i] = CRGB::Black;
// }
// }
// void onLed(int led) {
// for (int i = 0; i < 8; i++) {
// if (led == i) {
// leds[i] = CRGB(0, 255, 0);
// }
// }
// }
// void rekLama() {
// for (int repeat = 0; repeat < 1; repeat++) {
// for (int i = 0; i < 256; i++) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(0, i, 0); // Yashil rangda
// }
// FastLED.show();
// delay(20); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// // LEDlarni asta-sekin o'chirish
// for (int i = 255; i >= 0; i--) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(0, i, 0); // Qizil rangda
// }
// FastLED.show();
// delay(20); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// }
// for (int repeat = 0; repeat < 1; repeat++) {
// for (int i = 0; i < 256; i++) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(i, i, i); // Yashil rangda
// }
// FastLED.show();
// delay(20); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// // LEDlarni asta-sekin o'chirish
// for (int i = 255; i >= 0; i--) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(i, i, i); // Qizil rangda
// }
// FastLED.show();
// delay(20); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// }
// for (int repeat = 0; repeat < 1; repeat++) {
// for (int i = 0; i < 256; i++) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(0, i, 0); // Yashil rangda
// }
// FastLED.show();
// delay(10); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// // LEDlarni asta-sekin o'chirish
// for (int i = 255; i >= 0; i--) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(0, i, 0); // Qizil rangda
// }
// FastLED.show();
// delay(10); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// }
// for (int repeat = 0; repeat < 1; repeat++) {
// for (int i = 0; i < 256; i++) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(i, i, i); // Yashil rangda
// }
// FastLED.show();
// delay(10); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// // LEDlarni asta-sekin o'chirish
// for (int i = 255; i >= 0; i--) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(i, i, i); // Qizil rangda
// }
// FastLED.show();
// delay(10); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// }
// }
// // Fade Effect funksiyasi
// void fadeEffect() {
// // LEDlarni birin ketinlikda porlatish va yorqinligini oshirish
// for (int j = 0; j < NUM_LEDS; j++) {
// for (int i = 0; i < 256; i++) {
// leds[j] = CHSV(map(i, 0, 255, 120, 96), 255, i); // Hamma LEDlarni dimlashtirish, faqat j-chi LEDni porlatish
// FastLED.show(); // LEDlar yangilash
// delay(1); // Yorqinlikni asta-sekin oshirish uchun kutish
// }
// }
// // LEDlarni birin ketinlikda porlatib, yorqinligini kamaytirish
// for (int j = 0; j < NUM_LEDS; j++) {
// for (int i = 255; i >= 0; i--) {
// leds[j] = CHSV(0, 0, i); // Hamma LEDlarni dimlashtirish, faqat j-chi LEDni dimlash
// FastLED.show(); // LEDlar yangilash
// delay(2); // Yorqinlikni asta-sekin kamaytirish uchun kutish
// }
// }
// for (int j = NUM_LEDS - 1; j >= 0; j--) { // LEDlarni oxirgisidan boshlash
// // Yorqinligini oshirish (0 dan 255 gacha)
// for (int i = 0; i < 256; i++) {
// leds[j] = CHSV(map(i, 0, 255, 120, 96), 255, i); // Faqat j-chi LEDni porlatish
// FastLED.show(); // LEDlar yangilash
// delay(1); // Yorqinlikni oshirish uchun kutish
// }
// }
// // Keyin, LEDlar dimlanadi (yorqinlikni kamaytirish)
// for (int j = NUM_LEDS - 1; j >= 0; j--) { // LEDlarni oxirgisidan boshlash
// for (int i = 255; i >= 0; i--) {
// leds[j] = CHSV(0, 0, i); // Faqat j-chi LEDni dimlashtirish
// FastLED.show(); // LEDlar yangilash
// delay(2); // Yorqinlikni kamaytirish uchun kutish
// }
// }
// }
// void loop() {
// button_state_kalla = digitalRead(buttonKalla);
// button_state_dum = digitalRead(buttonDum);
// button_stateorqa_kalla = digitalRead(buttonOrqagaKalla);
// button_stateorqa_dum = digitalRead(buttonOrqagaDum);
// // kalla
// if (button_state_kalla != kalla_button_state) {
// if (button_state_kalla == HIGH) {
// digitalWrite(13, LOW);
// } else {
// digitalWrite(13, HIGH);
// button_pressed_count++;
// Serial.println(button_pressed_count); // monitorda tekshirish
// }
// delay(50);
// }
// // dum
// if (button_state_dum != dum_button_state) {
// if (button_state_dum == HIGH) {
// digitalWrite(13, LOW);
// } else {
// digitalWrite(13, HIGH);
// button_pressed_count_dum++;
// Serial.println(button_pressed_count_dum); // monitorda tekshirish
// }
// delay(50);
// }
// // kalla orqaga qaytish
// if (button_stateorqa_kalla != orqa_button_state_kalla) {
// if (button_stateorqa_kalla == LOW) {
// digitalWrite(13, HIGH);
// } else {
// digitalWrite(13, LOW);
// button_pressed_count--;
// int led_index = button_pressed_count-1; // LEDning indeksini hisoblash
// ofQora(button_pressed_count-1); // Mos keladigan LEDni o'chirish
// }
// delay(50);
// }
// // dum orqaga qaytish
// if (button_stateorqa_dum != orqa_button_state_dum) {
// if (button_stateorqa_dum == LOW) {
// digitalWrite(13, HIGH);
// } else {
// digitalWrite(13, LOW);
// button_pressed_count_dum--;
// // button_pressed_count_dum--;
// }
// delay(50);
// }
// kalla_button_state = button_state_kalla;
// dum_button_state = button_state_dum;
// orqa_button_state_kalla = button_stateorqa_kalla;
// orqa_button_state_dum = button_stateorqa_dum;
// if (button_pressed_count == 16) {
// offAllLeds();
// // rekLama();
// button_pressed_count = 0;
// }
// if(button_pressed_count_dum == 32){
// offAllLeds();
// // rekLama();
// button_pressed_count_dum = 16;
// }
// if (int(button_pressed_count / 16) % 2 == 1) {
// onLed(8 - int((button_pressed_count % 16) / 2));
// } else {
// onLed(int((button_pressed_count % 16) / 2) - 1);
// }
// // dum
// if (int(button_pressed_count_dum / 16) % 2 == 1) {
// onLed(8 - int((button_pressed_count_dum % 16) / 2));
// }
// else {
// onLed(6 - (int((button_pressed_count_dum % 16) / 2)));
// }
// if (button_pressed_count % 2 == 1) {
// unsigned long currentMillis = millis();
// if (currentMillis - previousMillis > interval) {
// previousMillis = currentMillis;
// int curred_led;
// if (button_pressed_count % 32 > 16) {
// curred_led = 7 - int(button_pressed_count % 16 / 2);
// } else {
// curred_led = int(button_pressed_count % 16 / 2);
// }
// if (leds[curred_led] == HIGH || leds[curred_led] == LOW) {
// leds[curred_led] = CRGB(250, 250, 250);
// } else {
// leds[curred_led] = CRGB::Black;
// }
// }
// }
// // dum
// if (button_pressed_count_dum % 2 == 1) {
// unsigned long currentMillis = millis();
// if (currentMillis - previousMillis > interval) {
// previousMillis = currentMillis;
// int curred_led;
// if (button_pressed_count_dum % 32 > 16) {
// curred_led = 7 - int(button_pressed_count_dum % 16 / 2);
// } else {
// curred_led = (6 - int(button_pressed_count_dum % 16 / 2));
// }
// if (leds[curred_led] == HIGH || leds[curred_led] == LOW) {
// leds[curred_led] = CRGB(250, 250, 250);
// } else {
// leds[curred_led] = CRGB::Black;
// }
// }
// }
// FastLED.show();
// }
// O'zbekiston tablo massa
// #include <FastLED.h>
// #define buttonKalla 4 // kalla uchun 4-knopka
// #define buttonDum 6 // dum uchun 7-knopka
// #define buttonOrqagaKalla 5 // kalla orqaga qaytish uchun 5-knopka
// #define buttonOrqagaDum 7 // dum orqaga qaytish uchun 5-knopka
// #define LED_PIN 13 // led pin 13
// #define NUM_LEDS 11 // ledlar soni
// // kalla
// int button_pressed_count = 1; // kalla
// int button_state_kalla = 0; // kalla
// int kalla_button_state = 0; // kalla
// // dum
// int button_pressed_count_dum = 23;
// int button_state_dum = 0; // dum
// int dum_button_state = 0; // dum
// // kalla orqaga qaytish
// int button_stateorqa_kalla = 0;
// int orqa_button_state_kalla = 0;
// // dum orqaga qaytish
// int button_stateorqa_dum = 0;
// int orqa_button_state_dum = 0;
// long interval = 500;
// long previousMillis = 0;
// unsigned long startTime;
// CRGB leds[NUM_LEDS];
// void setup() {
// Serial.begin(9600);
// pinMode(buttonKalla, INPUT_PULLUP);
// pinMode(buttonDum, INPUT_PULLUP);
// pinMode(buttonOrqagaKalla, INPUT_PULLUP);
// pinMode(buttonOrqagaDum, INPUT_PULLUP);
// FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
// Serial.println("Button count");
// fadeEffect();
// }
// void offAllLeds() {
// for (int i = 0; i < NUM_LEDS; i++) {
// leds[i] = CRGB::Black;
// }
// }
// void onLed(int led) {
// for (int i = 0; i < 11; i++) {
// if (led == i) {
// leds[i] = CRGB(0, 0, 255);
// }
// }
// }
// void rekLama() {
// for (int repeat = 0; repeat < 1; repeat++) {
// for (int i = 0; i < 256; i++) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(0, 0, i); // Yashil rangda
// }
// FastLED.show();
// delay(20); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// // LEDlarni asta-sekin o'chirish
// for (int i = 255; i >= 0; i--) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(0, 0, i); // Qizil rangda
// }
// FastLED.show();
// delay(20); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// }
// for (int repeat = 0; repeat < 1; repeat++) {
// for (int i = 0; i < 256; i++) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(i, i, i); // Yashil rangda
// }
// FastLED.show();
// delay(20); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// // LEDlarni asta-sekin o'chirish
// for (int i = 255; i >= 0; i--) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(i, i, i); // Qizil rangda
// }
// FastLED.show();
// delay(20); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// }
// for (int repeat = 0; repeat < 1; repeat++) {
// for (int i = 0; i < 256; i++) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(0, 0, i); // Yashil rangda
// }
// FastLED.show();
// delay(10); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// // LEDlarni asta-sekin o'chirish
// for (int i = 255; i >= 0; i--) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(0, 0, i); // Qizil rangda
// }
// FastLED.show();
// delay(10); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// }
// for (int repeat = 0; repeat < 1; repeat++) {
// for (int i = 0; i < 256; i++) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(i, i, i); // Yashil rangda
// }
// FastLED.show();
// delay(10); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// // LEDlarni asta-sekin o'chirish
// for (int i = 255; i >= 0; i--) {
// for (int j = 0; j < NUM_LEDS; j++) {
// leds[j] = CRGB(i, i, i); // Qizil rangda
// }
// FastLED.show();
// delay(10); // O'tish vaqtini o'zgartirishingiz mumkin
// }
// }
// }
// void rekLama(int times) {
// for (int i = 0; i < times; i++) {
// // LEDlarni yoqish
// fill_solid(leds, NUM_LEDS, CRGB::Blue); // LEDlarni oq rangda yoqish
// FastLED.show();
// delay(500); // 0.5 sekund davomida yoqish
// // LEDlarni o'chirish
// fill_solid(leds, NUM_LEDS, CRGB::Black); // LEDlarni o'chirish
// FastLED.show();
// delay(500); // 0.5 sekund davomida o'chirish
// }
// }
// // Fade Effect funksiyasi
// void fadeEffect() {
// // LEDlarni birin ketinlikda porlatish va yorqinligini oshirish
// for (int j = 0; j < NUM_LEDS; j++) {
// for (int i = 0; i < 256; i++) {
// leds[j] = CHSV(map(i, 0, 255, 85, 160), 255, i); // Hamma LEDlarni dimlashtirish, faqat j-chi LEDni porlatish
// FastLED.show(); // LEDlar yangilash
// delay(1); // Yorqinlikni asta-sekin oshirish uchun kutish
// }
// }
// // LEDlarni birin ketinlikda porlatib, yorqinligini kamaytirish
// for (int j = 0; j < NUM_LEDS; j++) {
// for (int i = 255; i >= 0; i--) {
// leds[j] = CHSV(0, 0, i); // Hamma LEDlarni dimlashtirish, faqat j-chi LEDni dimlash
// FastLED.show(); // LEDlar yangilash
// delay(2); // Yorqinlikni asta-sekin kamaytirish uchun kutish
// }
// }
// for (int j = NUM_LEDS - 1; j >= 0; j--) { // LEDlarni oxirgisidan boshlash
// // Yorqinligini oshirish (0 dan 255 gacha)
// for (int i = 0; i < 256; i++) {
// leds[j] = CHSV(map(i, 0, 255, 85, 160), 255, i); // Faqat j-chi LEDni porlatish
// FastLED.show(); // LEDlar yangilash
// delay(1); // Yorqinlikni oshirish uchun kutish
// }
// }
// // Keyin, LEDlar dimlanadi (yorqinlikni kamaytirish)
// for (int j = NUM_LEDS - 1; j >= 0; j--) { // LEDlarni oxirgisidan boshlash
// for (int i = 255; i >= 0; i--) {
// leds[j] = CHSV(0, 0, i); // Faqat j-chi LEDni dimlashtirish
// FastLED.show(); // LEDlar yangilash
// delay(2); // Yorqinlikni kamaytirish uchun kutish
// }
// }
// }
// void loop() {
// button_state_kalla = digitalRead(buttonKalla);
// button_state_dum = digitalRead(buttonDum);
// button_stateorqa_kalla = digitalRead(buttonOrqagaKalla);
// button_stateorqa_dum = digitalRead(buttonOrqagaDum);
// // kalla
// if (button_state_kalla != kalla_button_state) {
// if (button_state_kalla == HIGH) {
// digitalWrite(13, LOW);
// } else {
// digitalWrite(13, HIGH);
// button_pressed_count++;
// Serial.println(button_pressed_count);
// }
// delay(50);
// }
// // dum
// if (button_state_dum != dum_button_state) {
// if (button_state_dum == HIGH) {
// digitalWrite(13, LOW);
// } else {
// digitalWrite(13, HIGH);
// button_pressed_count_dum++;
// Serial.println(button_pressed_count_dum);
// }
// delay(50);
// }
// // kalla orqaga qaytish
// if (button_stateorqa_kalla != orqa_button_state_kalla) {
// if (button_stateorqa_kalla == LOW) {
// digitalWrite(13, HIGH);
// } else {
// digitalWrite(13, LOW);
// button_pressed_count--;
// }
// delay(50);
// }
// // dum orqaga qaytish
// if (button_stateorqa_dum != orqa_button_state_dum) {
// if (button_stateorqa_dum == LOW) {
// digitalWrite(13, HIGH);
// } else {
// digitalWrite(13, LOW);
// button_pressed_count_dum--;
// // button_pressed_count_dum--;
// }
// delay(50);
// }
// kalla_button_state = button_state_kalla;
// dum_button_state = button_state_dum;
// orqa_button_state_kalla = button_stateorqa_kalla;
// orqa_button_state_dum = button_stateorqa_dum;
// if (button_pressed_count == 22) {
// offAllLeds();
// rekLama(10);
// button_pressed_count = 0;
// }
// if(button_pressed_count_dum == 44){
// offAllLeds();
// rekLama(10);
// button_pressed_count_dum = 22;
// }
// if (int(button_pressed_count / 22) % 2 == 1) {
// onLed(11 - int((button_pressed_count % 22) / 2));
// } else {
// onLed(int((button_pressed_count % 22) / 2) - 1);
// }
// // dum
// if (int(button_pressed_count_dum / 22) % 2 == 1) {
// onLed(11 - int((button_pressed_count_dum % 22) / 2));
// } else {
// onLed(9 - (int((button_pressed_count_dum % 22) / 2)));
// }
// if (button_pressed_count % 2 == 1) {
// unsigned long currentMillis = millis();
// if (currentMillis - previousMillis > interval) {
// previousMillis = currentMillis;
// int curred_led;
// if (button_pressed_count % 44 > 22) {
// curred_led = 10 - int(button_pressed_count % 22 / 2);
// } else {
// curred_led = int(button_pressed_count % 22 / 2);
// }
// if (leds[curred_led] == HIGH || leds[curred_led] == LOW) {
// leds[curred_led] = CRGB(255, 255, 255);
// } else {
// leds[curred_led] = CRGB(0, 0, 0);
// }
// }
// }
// //dum
// if (button_pressed_count_dum % 2 == 1) {
// unsigned long currentMillis = millis();
// if (currentMillis - previousMillis > interval) {
// previousMillis = currentMillis;
// int curred_led;
// if (button_pressed_count_dum % 44 > 22) {
// curred_led = 10 - int(button_pressed_count_dum % 22 / 2);
// } else {
// curred_led = (9 - int(button_pressed_count_dum % 22 / 2));
// }
// if (leds[curred_led] == HIGH || leds[curred_led] == LOW) {
// leds[curred_led] = CRGB(255, 255, 255);
// } else {
// leds[curred_led] = CRGB(0, 0, 0);
// }
// }
// }
// FastLED.show();
// }
// // Test massa
// #include <FastLED.h>
// #define buttonKalla 4 // kalla uchun 4-knopka
// #define buttonDum 6 // dum uchun 7-knopka
// #define buttonOrqagaKalla 5 // kalla orqaga qaytish uchun 5-knopka
// #define buttonOrqagaDum 7 // dum orqaga qaytish uchun 5-knopka
// #define LED_PIN 13 // led pin 13
// #define NUM_LEDS 11 // ledlar soni
// // kalla
// int button_pressed_count = 1; // kalla
// int button_state_kalla = 0; // kalla
// int kalla_button_state = 0; // kalla
// // dum
// int button_pressed_count_dum = 23;
// int button_state_dum = 0; // dum
// int dum_button_state = 0; // dum
// // kalla orqaga qaytish
// int button_stateorqa_kalla = 0;
// int orqa_button_state_kalla = 0;
// // dum orqaga qaytish
// int button_stateorqa_dum = 0;
// int orqa_button_state_dum = 0;
// long interval = 500;
// long previousMillis = 0;
// unsigned long startTime;
// CRGB leds[NUM_LEDS];
// void setup() {
// Serial.begin(9600);
// pinMode(buttonKalla, INPUT_PULLUP);
// pinMode(buttonDum, INPUT_PULLUP);
// pinMode(buttonOrqagaKalla, INPUT_PULLUP);
// pinMode(buttonOrqagaDum, INPUT_PULLUP);
// FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
// Serial.println("Button count");
// // fadeEffect();
// }
// void offAllLeds() {
// for (int i = 0; i < NUM_LEDS; i++) {
// leds[i] = CRGB::Black;
// }
// }
// void onLed(int led) {
// for (int i = 0; i < 11; i++) {
// if (led == i) {
// leds[i] = CRGB(0, 0, 255);
// }
// }
// }
// // void rekLama(int times) {
// // for (int i = 0; i < times; i++) {
// // // LEDlarni yoqish
// // fill_solid(leds, NUM_LEDS, CRGB::Blue); // LEDlarni oq rangda yoqish
// // FastLED.show();
// // delay(500); // 0.5 sekund davomida yoqish
// // // LEDlarni o'chirish
// // fill_solid(leds, NUM_LEDS, CRGB::Black); // LEDlarni o'chirish
// // FastLED.show();
// // delay(500); // 0.5 sekund davomida o'chirish
// // }
// // }
// // Fade Effect funksiyasi
// // void fadeEffect() {
// // // LEDlarni birin ketinlikda porlatish va yorqinligini oshirish
// // for (int j = 0; j < NUM_LEDS; j++) {
// // for (int i = 0; i < 256; i++) {
// // leds[j] = CHSV(map(i, 0, 255, 85, 160), 255, i); // Hamma LEDlarni dimlashtirish, faqat j-chi LEDni porlatish
// // FastLED.show(); // LEDlar yangilash
// // delay(1); // Yorqinlikni asta-sekin oshirish uchun kutish
// // }
// // }
// // // LEDlarni birin ketinlikda porlatib, yorqinligini kamaytirish
// // for (int j = 0; j < NUM_LEDS; j++) {
// // for (int i = 255; i >= 0; i--) {
// // leds[j] = CHSV(0, 0, i); // Hamma LEDlarni dimlashtirish, faqat j-chi LEDni dimlash
// // FastLED.show(); // LEDlar yangilash
// // delay(2); // Yorqinlikni asta-sekin kamaytirish uchun kutish
// // }
// // }
// // for (int j = NUM_LEDS - 1; j >= 0; j--) { // LEDlarni oxirgisidan boshlash
// // // Yorqinligini oshirish (0 dan 255 gacha)
// // for (int i = 0; i < 256; i++) {
// // leds[j] = CHSV(map(i, 0, 255, 85, 160), 255, i); // Faqat j-chi LEDni porlatish
// // FastLED.show(); // LEDlar yangilash
// // delay(1); // Yorqinlikni oshirish uchun kutish
// // }
// // }
// // // Keyin, LEDlar dimlanadi (yorqinlikni kamaytirish)
// // for (int j = NUM_LEDS - 1; j >= 0; j--) { // LEDlarni oxirgisidan boshlash
// // for (int i = 255; i >= 0; i--) {
// // leds[j] = CHSV(0, 0, i); // Faqat j-chi LEDni dimlashtirish
// // FastLED.show(); // LEDlar yangilash
// // delay(2); // Yorqinlikni kamaytirish uchun kutish
// // }
// // }
// // }
// void loop() {
// button_state_kalla = digitalRead(buttonKalla);
// button_state_dum = digitalRead(buttonDum);
// button_stateorqa_kalla = digitalRead(buttonOrqagaKalla);
// button_stateorqa_dum = digitalRead(buttonOrqagaDum);
// // kalla
// if (button_state_kalla != kalla_button_state) {
// if (button_state_kalla == HIGH) {
// digitalWrite(13, LOW);
// } else {
// digitalWrite(13, HIGH);
// button_pressed_count++;
// Serial.println(button_pressed_count);
// }
// delay(50);
// }
// // dum
// if (button_state_dum != dum_button_state) {
// if (button_state_dum == HIGH) {
// digitalWrite(13, LOW);
// } else {
// digitalWrite(13, HIGH);
// button_pressed_count_dum++;
// Serial.println(button_pressed_count_dum);
// }
// delay(50);
// }
// // kalla orqaga qaytish
// if (button_stateorqa_kalla != orqa_button_state_kalla) {
// if (button_stateorqa_kalla == LOW) {
// digitalWrite(13, HIGH);
// } else {
// digitalWrite(13, LOW);
// button_pressed_count--;
// }
// delay(50);
// }
// // dum orqaga qaytish
// if (button_stateorqa_dum != orqa_button_state_dum) {
// if (button_stateorqa_dum == LOW) {
// digitalWrite(13, HIGH);
// } else {
// digitalWrite(13, LOW);
// button_pressed_count_dum--;
// // button_pressed_count_dum--;
// }
// delay(50);
// }
// kalla_button_state = button_state_kalla;
// dum_button_state = button_state_dum;
// orqa_button_state_kalla = button_stateorqa_kalla;
// orqa_button_state_dum = button_stateorqa_dum;
// if (button_pressed_count == 22) {
// offAllLeds();
// // rekLama(10);
// button_pressed_count = 0;
// }
// if(button_pressed_count_dum == 44){
// offAllLeds();
// // rekLama(10);
// button_pressed_count_dum = 22;
// }
// if (int(button_pressed_count / 22) % 2 == 1) {
// onLed(11 - int((button_pressed_count % 22) / 2));
// } else {
// onLed(int((button_pressed_count % 22) / 2) - 1);
// }
// // dum
// if (int(button_pressed_count_dum / 22) % 2 == 1) {
// onLed(11 - int((button_pressed_count_dum % 22) / 2));
// } else {
// onLed(9 - (int((button_pressed_count_dum % 22) / 2)));
// }
// if (button_pressed_count % 2 == 1) {
// unsigned long currentMillis = millis();
// if (currentMillis - previousMillis > interval) {
// previousMillis = currentMillis;
// int curred_led;
// if (button_pressed_count % 44 > 22) {
// curred_led = 10 - int(button_pressed_count % 22 / 2);
// } else {
// curred_led = int(button_pressed_count % 22 / 2);
// }
// if (leds[curred_led] == HIGH || leds[curred_led] == LOW) {
// leds[curred_led] = CRGB(255, 255, 255);
// } else {
// leds[curred_led] = CRGB(0, 0, 0);
// }
// }
// }
// //dum
// if (button_pressed_count_dum % 2 == 1) {
// unsigned long currentMillis = millis();
// if (currentMillis - previousMillis > interval) {
// previousMillis = currentMillis;
// int curred_led;
// if (button_pressed_count_dum % 44 > 22) {
// curred_led = 10 - int(button_pressed_count_dum % 22 / 2);
// } else {
// curred_led = (9 - int(button_pressed_count_dum % 22 / 2));
// }
// if (leds[curred_led] == HIGH || leds[curred_led] == LOW) {
// leds[curred_led] = CRGB(255, 255, 255);
// } else {
// leds[curred_led] = CRGB(0, 0, 0);
// }
// }
// }
// FastLED.show();
// }
// Chilonzor massa
#include <FastLED.h>
#define buttonKalla 4 // kalla uchun 4-knopka
#define buttonDum 6 // dum uchun 7-knopka
#define buttonOrqagaKalla 5 // kalla orqaga qaytish uchun 5-knopka
#define buttonOrqagaDum 7 // dum orqaga qaytish uchun 5-knopka
#define LED_PIN 13 // led pin 13
#define NUM_LEDS 17 // ledlar soni
// kalla
int button_pressed_count = 1; // kalla
int button_state_kalla = 0; // kalla
int kalla_button_state = 0; // kalla
// dum
int button_pressed_count_dum = 35;
int button_state_dum = 0; // dum
int dum_button_state = 0; // dum
// kalla orqaga qaytish
int button_stateorqa_kalla = 0;
int orqa_button_state_kalla = 0;
// dum orqaga qaytish
int button_stateorqa_dum = 0;
int orqa_button_state_dum = 0;
long interval = 500;
long previousMillis = 0;
unsigned long startTime;
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
pinMode(buttonKalla, INPUT_PULLUP);
pinMode(buttonDum, INPUT_PULLUP);
pinMode(buttonOrqagaKalla, INPUT_PULLUP);
pinMode(buttonOrqagaDum, INPUT_PULLUP);
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
Serial.println("Button count");
// fadeEffect();
}
void offAllLeds() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Black;
}
}
void onLed(int led) {
for (int i = 0; i < 17; i++) {
if (led == i) {
leds[i] = CRGB(255, 0, 0);
}
}
}
void rekLama(int times) {
for (int i = 0; i < times; i++) {
// LEDlarni yoqish
fill_solid(leds, NUM_LEDS, CRGB::Red); // LEDlarni oq rangda yoqish
FastLED.show();
delay(500); // 0.5 sekund davomida yoqish
// LEDlarni o'chirish
fill_solid(leds, NUM_LEDS, CRGB::Black); // LEDlarni o'chirish
FastLED.show();
delay(500); // 0.5 sekund davomida o'chirish
}
}
void loop() {
button_state_kalla = digitalRead(buttonKalla);
button_state_dum = digitalRead(buttonDum);
button_stateorqa_kalla = digitalRead(buttonOrqagaKalla);
button_stateorqa_dum = digitalRead(buttonOrqagaDum);
// kalla
if (button_state_kalla != kalla_button_state) {
if (button_state_kalla == HIGH) {
digitalWrite(13, LOW);
} else {
digitalWrite(13, HIGH);
button_pressed_count++;
Serial.println(button_pressed_count);
}
delay(50);
}
// dum
if (button_state_dum != dum_button_state) {
if (button_state_dum == HIGH) {
digitalWrite(13, LOW);
} else {
digitalWrite(13, HIGH);
button_pressed_count_dum++;
Serial.println(button_pressed_count_dum);
}
delay(50);
}
// kalla orqaga qaytish
if (button_stateorqa_kalla != orqa_button_state_kalla) {
if (button_stateorqa_kalla == LOW) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
button_pressed_count--;
}
delay(50);
}
// dum orqaga qaytish
if (button_stateorqa_dum != orqa_button_state_dum) {
if (button_stateorqa_dum == LOW) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
button_pressed_count_dum--;
// button_pressed_count_dum--;
}
delay(50);
}
kalla_button_state = button_state_kalla;
dum_button_state = button_state_dum;
orqa_button_state_kalla = button_stateorqa_kalla;
orqa_button_state_dum = button_stateorqa_dum;
if (button_pressed_count == 34) {
offAllLeds();
rekLama(10);
button_pressed_count = 0;
}
if(button_pressed_count_dum == 68){
offAllLeds();
rekLama(10);
button_pressed_count_dum = 34;
}
if (int(button_pressed_count / 34) % 2 == 1) {
onLed(17 - int((button_pressed_count % 34) / 2));
} else {
onLed(int((button_pressed_count % 34) / 2) - 1);
}
// dum
if (int(button_pressed_count_dum / 34) % 2 == 1) {
onLed(17 - int((button_pressed_count_dum % 34) / 2));
} else {
onLed(15 - (int((button_pressed_count_dum % 34) / 2)));
}
if (button_pressed_count % 2 == 1) {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
int curred_led;
if (button_pressed_count % 68 > 34) {
curred_led = 16 - int(button_pressed_count % 34 / 2);
} else {
curred_led = int(button_pressed_count % 34 / 2);
}
if (leds[curred_led] == HIGH || leds[curred_led] == LOW) {
leds[curred_led] = CRGB(255, 255, 255);
} else {
leds[curred_led] = CRGB(0, 0, 0);
}
}
}
//dum
if (button_pressed_count_dum % 2 == 1) {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
int curred_led;
if (button_pressed_count_dum % 68 > 34) {
curred_led = 16 - int(button_pressed_count_dum % 34 / 2);
} else {
curred_led = (15 - int(button_pressed_count_dum % 34 / 2));
}
if (leds[curred_led] == HIGH || leds[curred_led] == LOW) {
leds[curred_led] = CRGB(255, 255, 255);
} else {
leds[curred_led] = CRGB(0, 0, 0);
}
}
}
FastLED.show();
}