Tuesday, March 26, 2024

Nguyễn Phương Hà lừa đảo

Hôm nay ngày 26/3/2024

mình bị đối tượng nữ tên: Nguyễn Phương Hà 

sdt zalo: 0876488623 (087.648.8623) 

lợi dụng chuyển khoản qua MBBank qua stk: 0001863302156, 

nhưng được báo lại là hệ thống không nạp tiền thành công, 

yêu cầu nạp cho đủ 800k nhưng mình không làm theo,

nghi ngờ chiêu bài nạp tiền nhiều lần như trên truyền hình đưa tin, nên mình đã không tiếp tục làm theo yêu cầu chuyển tiền thêm và yêu cầu hoàn trả tiền đã chuyển,

mình bị khoá tin nhắn và cuộc gọi zalo, 

bị lừa qua zalo vài lần rồi, ứng dụng k đáng tin, k hỗ trợ giải quyết, k thấy kết quả giải quyết, và k thấy tài khoản lừa đảo bị khóa gì cả.

Vietcombank không hề lắng nghe tiếp nhận ghi nhận xử lý thông tin, đẩy hết trách nhiệm qua ngân hàng liên kết trực tiếp chuyển khoản, không ghi nhận tài khoản lừa đảo.

Momo cũng không hỗ trợ giải quyết, bảo liên hệ cơ quan chức năng nhưng không cung cấp thông tin để liên hệ như địa chỉ, số điện thoại, email hay bất cứ gì thêm, quá thất vọng.

hiện tại mình đang cập nhật VNid để cập nhật hồ sơ báo cáo và đăng thông tin này trên cách cộng đồng để mọi người kịp tìm kiếm số điện thoại trước khi chuyển khoản để kịp thời tránh, mong cộng đồng chia sẻ để loại trừ những con người vô lương tâm đạo đức như thế này.







Wednesday, January 4, 2023

Image and charset to FNT

 Input:
*.png Image contain image characters from left to right

paste text of characters from left to right, ex: x123456789

Output:

program will read image by rectangle from left to right, output characters, atlas of characters in Power of 2 with *.fnt file match image name


Download:

https://drive.google.com/open?id=1-cfk0-G9lIdJ2I3jMDB6l6wfWjKJcyF-&authuser=zxcongducxz%40gmail.com&usp=drive_fs


Saturday, December 18, 2021

Arduino Uno - 4-Bit LED Digital Module - 3461BS - 5 pins - without library but can display whatever you want


Require components:

1x Arduino Uno

5x wires

1x 4-Bit LED Digital Module using 4-digit LED display model 3461BS


Link 256 states of 7 segment digit

https://zxcongducxz.000webhostapp.com/arduino/SevenSegmentLEDDisplay.html


Video:


Code:

// 4-Bit LED Digital Module with 2x 74HC595D-chip, there are 5 pins from top to bottom:
// VCC  : pin 5V; 
// SCLK : pin A0; 
// SRLK : pin A1; 
// DIO  : pin A3
// GND  : pin GND
#define PIN_SCLK A0 // serial clock, set LOW & HIGH after set PIN_DIO
#define PIN_RCLK A1 // register clock, set LOW & HIGH after write digit
#define PIN_DIO  A2 // set PIN_DIO set index bit from 0,1,2,3,4,5,6,7 = A,B,C,D,E,F,G,DP
const byte TOTAL_DIGITS = 4; // default is 4, you may need to change this value depends on amounts of digits on your module, i'm not sure will it work if changed, good luck ;))
const byte BYTES_0_TO_9[] = { // list of bytes to display from top to bottom, 1 byte = 8 bits, bit starts from right to left, from left to right are DotPoint,G,F,E,D,C,B,A
  B00111111, // 0
  B00000110, // 1
  B01011011, // 2
  B01001111, // 3
  B01100110, // 4 
  B01101101, // 5
  B01111101, // 6
  B00000111, // 7
  B01111111, // 8
  B01101111, // 9
};
const unsigned int POW_10[] = { // cache value for saving performance, https://www.arduino.cc/reference/en/language/functions/math/pow/
  1,        // pow(10, 0);
  10,       // pow(10, 1);
  100,      // pow(10, 2);
  1000,     // pow(10, 3);
  10000,    // pow(10, 4);
  100000,   // pow(10, 5);
  1000000,  // pow(10, 6);
  10000000, // pow(10, 7);
};
const byte BYTE_NEGATIVE = B01000000;
const byte BYTE_CELSIUS = B00111001;
const byte BYTE_FAHRENHEIT = B01110001;
const byte BYTE_DOT_POINT = B10000000;
const byte BYTE_VOLTAGE = B00111110;
const byte BYTE_AMPERE = B01110111;
const byte MIN_PERCENT = 0;
const byte MAX_PERCENT = 100;

void setup() {
  pinMode(PIN_SCLK, OUTPUT);
  pinMode(PIN_RCLK, OUTPUT);
  pinMode(PIN_DIO, OUTPUT);

  digitalWrite(PIN_SCLK, HIGH);
  digitalWrite(PIN_RCLK, HIGH);
  digitalWrite(PIN_DIO, HIGH);
}

void write(unsigned short durationbyte dataPGFEDCBA[]) {
  do {
    for(byte indexDigit = 0; indexDigit < TOTAL_DIGITS; indexDigit++) { // write each digits from most right to most left
      digitalWrite(PIN_RCLK, LOW);
      shiftOut(PIN_DIO, PIN_SCLK, MSBFIRST, ~dataPGFEDCBA[indexDigit]); // shift out byte display 8 bit display PGFEDCBA, because of we are using 4-digit common anode, need inverse bit by using "~" 
      shiftOut(PIN_DIO, PIN_SCLK, MSBFIRST, 1 << indexDigit); // shift out byte display 8 bit display digits
      // there is another way to set 16 bits, instead of shiftOut
      // is make 3 line of code for 16 times, just change isOn variable for each bit of bytePGFEDCBA & byteDigit from most left to most right ;))
      // digitalWrite(PIN_DIO, isOn); digitalWrite(PIN_DIO, isOn); digitalWrite(PIN_SCLK, HIGH);
      digitalWrite(PIN_RCLK, HIGH);
    }
  } while(duration-- > 0); // avoid case duration = 0--
}

void writeInt(unsigned short durationint number) { // 4 digit display from -999 to 9999, short is enough for 4 digit, but i wanted to support up to 8 digits, then i use int
  byte dataPGFEDCBA[TOTAL_DIGITS];
  
  byte totalDigit;  
  if(number >= 0) { // zero and positive numbers
    totalDigit = TOTAL_DIGITS; // show full digits
  } else { // negative numbers
    totalDigit = TOTAL_DIGITS - 1; // can not show full digits because of most left digit display negative symbol
    dataPGFEDCBA[totalDigit] = BYTE_NEGATIVE; // show negative symbol "-";
    number *= -1; // convert to positive number
  }
  for(byte indexDigit = 0; indexDigit < totalDigit; indexDigit++) {
    dataPGFEDCBA[indexDigit] = BYTES_0_TO_9[(unsigned short)(number / POW_10[indexDigit]) % 10];
  }
  
  write(duration, dataPGFEDCBA);
}

void writeFloat(unsigned short durationfloat number) { // 4 digit display from -99.9 to 999.9
  byte dataPGFEDCBA[TOTAL_DIGITS];
  
  byte totalDigit;  
  if(number >= 0) { // zero and positive numbers
    totalDigit = TOTAL_DIGITS; // show full digits
  } else { // negative numbers
    totalDigit = TOTAL_DIGITS - 1; // can not show full digits because of most left digit display negative symbol
    dataPGFEDCBA[totalDigit] = BYTE_NEGATIVE; // show negative symbol "-";
    number *= -1; // convert to positive number
  }
  dataPGFEDCBA[0] = BYTES_0_TO_9[(unsigned short)(number * 10) % 10]; // number after dot
  dataPGFEDCBA[1] = BYTES_0_TO_9[(unsigned short)(number) % 10] | BYTE_DOT_POINT;  // number before dot  
  for(byte indexDigit = 2; indexDigit < totalDigit; indexDigit++) {
    dataPGFEDCBA[indexDigit] = BYTES_0_TO_9[(unsigned short)(number / POW_10[indexDigit - 1]) % 10]; // remain numbers
  }
  
  write(duration, dataPGFEDCBA);
}

void writeIntUnit(unsigned short durationint numberbyte byteUnit) { // 4 digit display from -99 to 999, short is enough for 4 digit, but i wanted to support up to 8 digits, then i use int
  byte dataPGFEDCBA[TOTAL_DIGITS];
  dataPGFEDCBA[0] = byteUnit; // write unit
  
  byte totalDigit;  
  if(number >= 0) { // zero and positive numbers
    totalDigit = TOTAL_DIGITS; // show full digits
  } else { // negative numbers
    totalDigit = TOTAL_DIGITS - 1; // can not show full digits because of most left digit display negative symbol
    dataPGFEDCBA[totalDigit] = BYTE_NEGATIVE; // show negative symbol "-";
    number *= -1; // convert to positive number
  }
  for(byte indexDigit = 1; indexDigit < totalDigit; indexDigit++) {
    dataPGFEDCBA[indexDigit] = BYTES_0_TO_9[(unsigned short)(number / POW_10[indexDigit - 1]) % 10];
  }
  write(duration, dataPGFEDCBA);
}

void writeFloatUnit(unsigned short durationfloat numberbyte byteUnit) { // 4 digit display from -9.9 to 99.9
  byte dataPGFEDCBA[TOTAL_DIGITS];

  if(number >= 0) { // zero and positive numbers
    dataPGFEDCBA[3] = BYTES_0_TO_9[(unsigned short)(number / 10) % 10];
  } else { // negative numbers
    dataPGFEDCBA[3] = BYTE_NEGATIVE; // show negative symbol "-";
    number *= -1; // convert to positive number
  }
  dataPGFEDCBA[0] = byteUnit; // write symbol
  dataPGFEDCBA[1] = BYTES_0_TO_9[(unsigned short)(number * 10) % 10]; // number after dot
  dataPGFEDCBA[2] = BYTES_0_TO_9[(unsigned short)(number) % 10] | BYTE_DOT_POINT; // number before dot
  
  write(duration, dataPGFEDCBA);
}

void writeTime(unsigned short durationbyte hoursbyte minutes) {
  byte dataPGFEDCBA[TOTAL_DIGITS];
  
  dataPGFEDCBA[0] = BYTES_0_TO_9[minutes % 10];
  dataPGFEDCBA[1] = BYTES_0_TO_9[minutes / 10 % 10];
  dataPGFEDCBA[2] = BYTES_0_TO_9[hours % 10] | BYTE_DOT_POINT;
  dataPGFEDCBA[3] = BYTES_0_TO_9[hours / 10 % 10];
  
  write(duration, dataPGFEDCBA);
}

void writeText(unsigned short durationbyte data[]) { // length of data == TOTAL_DIGITS
  byte dataPGFEDCBA[TOTAL_DIGITS];
  for(byte indexDigit = 0; indexDigit < TOTAL_DIGITS; indexDigit++) {
    dataPGFEDCBA[indexDigit] = data[TOTAL_DIGITS - indexDigit - 1];
  }
  write(duration, dataPGFEDCBA);
}

void writePercent(unsigned short durationbyte data[], byte animationLengthbyte percent) { // support percent from 0 to 100
  byte dataPGFEDCBA[TOTAL_DIGITS];
  for(byte indexDigit = 0; indexDigit < TOTAL_DIGITS; indexDigit++) { // check all digits from most right to most left
    dataPGFEDCBA[indexDigit] = 0; // initialize value = 0, change later
    for(byte indexAnimation = 0; indexAnimation < animationLength; indexAnimation++) {
      byte percentCurrent = MAX_PERCENT * ((TOTAL_DIGITS - indexDigit) * animationLength - indexAnimation) / (TOTAL_DIGITS * animationLength);
      if(percentCurrent <= percent) { // is percent can be display
        dataPGFEDCBA[indexDigit] = data[indexAnimation];
        break
      }
    }
  }
  write(duration, dataPGFEDCBA);
}

void writeTextRunLeft(unsigned short delayMovebyte data[], unsigned short length) {
  for(unsigned short offset = 0; offset < length; offset++) {
    // slice
    byte dataPGFEDCBA[TOTAL_DIGITS];
    for(byte indexDigit = 0; indexDigit < TOTAL_DIGITS && indexDigit < length; indexDigit++) {
      dataPGFEDCBA[indexDigit] = data[(offset + indexDigit) % length];
    }
    writeText(delayMove, dataPGFEDCBA);
  }
}

void testInt() {
  for(int value = -999; value <= 9999; value++){
    writeInt(0, value);
  }
}

void testFloat() {
  for(float value = -99.9; value <= 999.9; value+=0.5){
    writeFloat(10, value);
  }
}

void testIntUnit() {
  for(int value = -99; value <= 999; value++){
    writeIntUnit(10, value, BYTE_CELSIUS);
  }
  for(int value = -99; value <= 999; value++){
    writeIntUnit(10, value, BYTE_FAHRENHEIT);
  }
  for(int value = -99; value <= 999; value++){
    writeIntUnit(10, value, BYTE_VOLTAGE);
  }
  for(int value = -99; value <= 999; value++){
    writeIntUnit(10, value, BYTE_AMPERE);
  }
}

void testFloatUnit() {
  for(float value = -9.9; value <= 99.9; value += 0.5){
    writeFloatUnit(20, value, BYTE_CELSIUS);
  }
  for(float value = -9.9; value <= 99.9; value += 0.5){
    writeFloatUnit(20, value, BYTE_FAHRENHEIT);
  }
  for(float value = -9.9; value <= 99.9; value += 0.5){
    writeFloatUnit(20, value, BYTE_VOLTAGE);
  }
  for(float value = -9.9; value <= 99.9; value += 0.5){
    writeFloatUnit(20, value, BYTE_AMPERE);
  }
}

void testTime() {
  for(byte hour = 0; hour < 24; hour++) {
    for(byte minute = 0; minute < 60; minute++){
      writeTime(10, hour, minute);
    }
  }
}

void testProgress() {
  byte durationPercent = 20;
  
  byte percent = 0;
  byte dataPGFEDCBA1[] = {B00110110, B00110000};
  do { writePercent(durationPercent, dataPGFEDCBA1, sizeof(dataPGFEDCBA1), percent); } while(++percent <= MAX_PERCENT); // fade in
  do { writePercent(durationPercent, dataPGFEDCBA1, sizeof(dataPGFEDCBA1), percent); } while(percent-- > 0); // fade out

  percent = 0;
  byte dataPGFEDCBA2[] = {B00110110, B00110010, B00110000, B00100000};
  do { writePercent(durationPercent, dataPGFEDCBA2, sizeof(dataPGFEDCBA2), percent); } while(++percent <= MAX_PERCENT); // fade in
  do { writePercent(durationPercent, dataPGFEDCBA2, sizeof(dataPGFEDCBA2), percent); } while(percent-- > 0); // fade out

  percent = 0;
  byte dataPGFEDCBA3[] = {B01001001,B01000001,B00000001};
  do { writePercent(durationPercent, dataPGFEDCBA3, sizeof(dataPGFEDCBA3), percent); } while(++percent <= MAX_PERCENT); // fade in
  do { writePercent(durationPercent, dataPGFEDCBA3, sizeof(dataPGFEDCBA3), percent); } while(percent-- > 0); // fade out
}

void testText() {
  byte dataPGFEDCBA[] = {
    B01110011, // P
    B00110000, // l, I (left)
    B11011100, // a
    B01101110, // Y, y
  };  
  writeText(1000, dataPGFEDCBA);
}

void testRunningText() {
  byte dataPGFEDCBA[] = {
    B01110110, // H
    B01111001, // E
    B00110110, // ll
    B01011100, // o
    B00000000, // (space)
    B00111110, // U,V
    B00111110, // U,V
    B01011100, // o
    B01010000, // r
    B00110000, // l, I (left)
    B01011110, // d
    B00000000, // (space)
  };
  writeTextRunLeft(1000, dataPGFEDCBA, sizeof(dataPGFEDCBA));
}

void loop() 
{
  testInt();
  testFloat();
  testIntUnit();
  testFloatUnit();
  testTime();
  testProgress();
  testText();
  testRunningText();
}

If my code can not be used, you may need to use other libraries on the internet:

https://github.com/monotok/FourBitDisplay

https://github.com/0xF6/TM74

https://github.com/avishorp/TM1637

https://github.com/DeanIsMe/SevSeg

https://github.com/Erriez/ErriezRobotDyn4DigitDisplay

https://github.com/bremme/arduino-tm1637


Tuesday, December 14, 2021

Arduino Uno - Traffic Light LED Red/Yellow/Green



 Require components:

1x Arduino Uno

1x Traffic Light

4x red/black/yellow/green wires


Video:


Code:

const byte PIN_GREEN = 11;
const byte PIN_YELLOW = 10;
const byte PIN_RED = 9;

void setup() {
  pinMode(PIN_GREEN, OUTPUT);
  pinMode(PIN_YELLOW, OUTPUT);
  pinMode(PIN_RED, OUTPUT);
  Serial.begin(9600);
}

void setColor(byte redbyte yellowbyte green) {
  Serial.print("setColor(");
  Serial.print(red);
  Serial.print(", ");
  Serial.print(yellow);
  Serial.print(", ");
  Serial.print(green);
  Serial.println(") ");
  analogWrite(PIN_RED, red);
  analogWrite(PIN_YELLOW, yellow);
  analogWrite(PIN_GREEN, green);
}

void show1LED() {
  Serial.println("show1LED()");
  setColor(25500); delay(1000); // red
  setColor(02550); delay(1000); // yellow
  setColor(00255); delay(1000); // green
}

void show2LEDs() {
  Serial.println("show2LEDs()");
  setColor(2552550); delay(1000); // red & yellow
  setColor(0255255); delay(1000); // yellow & green
  setColor(2550255); delay(1000); // red & green
}

void show3LEDs() {
  Serial.println("show3LEDs()");
  setColor(000); delay(1000);       // turn off
  setColor(255255255); delay(1000); // turn on all colors
  setColor(000); delay(1000);       // turn off
}

void fadeColor(byte redbyte yellowbyte green) {
  Serial.print("fadeColor(");
  Serial.print(red);
  Serial.print(", ");
  Serial.print(yellow);
  Serial.print(", ");
  Serial.println(green);

  byte total = 8; // should mod for 256 = 0;
  for(byte current = 0; current <= total; current++) { // fade in
    byte r = red / total * current ;
    byte y = yellow / total * current;
    byte g = green / total * current;
    setColor(r, y, g);
    delay(100);    
  }

  for(byte current = total - 1; current > 0; current--) { // fade out
    red = red / total * current;
    yellow = yellow / total * current;
    green = green / total * current;
    setColor(red, yellow, green);
    delay(100);
  }

  setColor(000);
  delay(100);
}

void fade1LED() {
  Serial.println("fade1LED()");
  fadeColor(25500); delay(1000); // red
  fadeColor(02550); delay(1000); // yellow
  fadeColor(00255); delay(1000); // green
}

void fade2LEDs() {
  Serial.println("fade2LEDs()");
  fadeColor(2552550); delay(1000); // red & yellow
  fadeColor(0255255); delay(1000); // yellow & green
  fadeColor(2550255); delay(1000); // red & green
}

void fade3LEDs() {
  Serial.println("fade3LEDs()");
  fadeColor(000); delay(1000);       // turn off
  fadeColor(255255255); delay(1000); // turn on all colors
  fadeColor(000); delay(1000);       // turn off
}

void showAllColors() {
  Serial.println("showAllColors()");
  byte increasement = 32; // should mod for 256 = 0, ex: 1, 2, 4, 6, 8, 16, 32, 64, 128, 256
  for(short red = 0; red <= 256; red += increasement) {
    for(short yellow = 0; yellow <= 256; yellow += increasement) {
      for(short green = 0; green <= 256; green += increasement) {          
        setColor(min(255, red), min(255, yellow), min(255, green));
        delay(100);
      }
    }
  }
}

void loop() {
  show1LED();
  show2LEDs();
  show3LEDs();
  
  fade1LED();
  fade2LEDs();
  fade3LEDs();
  
  showAllColors();
}



Monday, December 13, 2021

Arduino Uno - HW-481 CNT5 (Ky034) - 7-Colour flash module

 


Require components for test 3.3V:

1x Arduino Uno

1x red wire

1x black wire

1x HW-481 CNT5

Code effect 1:

const byte PIN_OUTPUT = 11;

void setup() {
  pinMode(PIN_OUTPUT, OUTPUT);
  digitalWrite(PIN_OUTPUT, HIGH);
}

void loop() {}



Require components for test pin:

1x Arduino Uno

2x red wire

2x black wire

1x HW-481 CNT5

Code effect 2:

const byte PIN_OUTPUT = 11; // the PWM pin the LED is attached to
byte brightness = 0;         // how bright the LED is
int fadeAmount = 5;         // how many points to fade the LED by

void setup() {
  pinMode(PIN_OUTPUT, OUTPUT); // declare pin output
}

void loop() {
  analogWrite(PIN_OUTPUT, brightness);  // set the brightness of pin
  brightness = brightness + fadeAmount;  // change the brightness for next time through the loop
  if (brightness <= 0 || brightness >= 255) { // reverse the direction of the fading at the ends of the fade
    fadeAmount = -fadeAmount;
  }
  delay(30);  // wait for 30 milliseconds to see the dimming effect
}


Code effect 3:

const byte PIN_OUTPUT = 11; // the PWM pin the LED is attached to
const byte FADE_AMOUNT = 5; // how many points to fade the LED by
const byte DELAY_DIMMING_EFFECT = 30; // milisecond
const unsigned short DELAY_FLASH_EFFECT = 10000; // milisecond
const unsigned short DELAY_END_ANIMATION = 3000; // milisecond

void setup() {
  pinMode(PIN_OUTPUT, OUTPUT); // declare pin output
}

void loop() {
  for(short brightness = 0; brightness <= 255; brightness += FADE_AMOUNT) {
    analogWrite(PIN_OUTPUT, brightness);  // set fade in
    delay(DELAY_DIMMING_EFFECT);
  }
  
  delay(DELAY_FLASH_EFFECT); // default flash effect

  for(short brightness = 255 - FADE_AMOUNT; brightness >= 0; brightness -= FADE_AMOUNT) {
    analogWrite(PIN_OUTPUT, brightness);  // set fade out
    delay(DELAY_DIMMING_EFFECT);
  }

  delay(DELAY_END_ANIMATION); // turn off
}

Video:








Sunday, December 12, 2021

LED RGB Common cathode - HW-479 2037 (Ky016)


 Require components:

1x Arduino Uno

4x wires

1x LED RGB HW-479 (K016)


Video:


Code test 1:

int redpin = 11;
int greenpin = 10;
int bluepin = 9;

int val;

void setup() {
  pinMode(redpin, OUTPUT);
  pinMode(bluepin, OUTPUT);
  pinMode(greenpin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  for(val = 255; val > 0; val--)
  {
    analogWrite(11, val);
    analogWrite(10255 - val);
    analogWrite(9128 - val);

    Serial.println(val, DEC);
    delay(5); 
  }
  for(val = 0; val < 255; val++)
  {
    analogWrite(11, val);
    analogWrite(10255 - val);
    analogWrite(9128 - val);
    
    Serial.println(val, DEC);
    delay(5); 
  }
}

Code switch basic colors:

const byte PIN_RED = 11;
const byte PIN_GREEN = 10;
const byte PIN_BLUE = 9;

const byte COLOR_RED[] = {255,0,0};
const byte COLOR_LIME[] = {0,255,0};
const byte COLOR_BLUE[] = {0,0,255};
const byte COLOR_WHITE[] = {255,255,255};
const byte COLOR_YELLOW[] = {255,255,0};
const byte COLOR_CYAN[] = {0,255,255};
const byte COLOR_MAGENTA[] = {255,0,255};
const byte COLOR_SILVER[] = {192,192,192};
const byte COLOR_GRAY[] = {128,128,128};
const byte COLOR_MAROON[] = {128,0,0};
const byte COLOR_OLIVE[] = {128,128,0};
const byte COLOR_GREEN[] = {0,128,0};
const byte COLOR_PURPLE[] = {128,0,128};
const byte COLOR_TEAL[] = {0,128,128};
const byte COLOR_NAVY[] = {0,0,128};

const unsigned short DURATION_COLOR = 1000;

void setup() {
  pinMode(PIN_RED, OUTPUT);
  pinMode(PIN_GREEN, OUTPUT);
  pinMode(PIN_BLUE, OUTPUT);
}

void setColor(byte colors[]) {
  analogWrite(PIN_RED, colors[0]);
  analogWrite(PIN_GREEN, colors[1]);
  analogWrite(PIN_BLUE, colors[2]);
}

void loop() {
  setColor(COLOR_RED); delay(DURATION_COLOR);
  setColor(COLOR_LIME); delay(DURATION_COLOR);
  setColor(COLOR_BLUE); delay(DURATION_COLOR);
  setColor(COLOR_WHITE); delay(DURATION_COLOR);
  setColor(COLOR_YELLOW); delay(DURATION_COLOR);
  setColor(COLOR_MAGENTA); delay(DURATION_COLOR);
  setColor(COLOR_SILVER); delay(DURATION_COLOR);
  setColor(COLOR_GRAY); delay(DURATION_COLOR);
  setColor(COLOR_MAROON); delay(DURATION_COLOR);
  setColor(COLOR_OLIVE); delay(DURATION_COLOR);
  setColor(COLOR_GREEN); delay(DURATION_COLOR);
  setColor(COLOR_PURPLE); delay(DURATION_COLOR);
  setColor(COLOR_TEAL); delay(DURATION_COLOR);
  setColor(COLOR_NAVY); delay(DURATION_COLOR);
}


Color switch multi colors

const byte PIN_RED = 11;
const byte PIN_GREEN = 10;
const byte PIN_BLUE = 9;

const byte AMOUNT_INCREASE = 32;  // min=1ms, but 255*255*255 = 16,581,375ms = 276 minutes, values should be 8, 16, 32, 64, 128
const unsigned short DURATION_COLOR = 100;  // min=1ms, delay next color

void setup() {
  pinMode(PIN_RED, OUTPUT);
  pinMode(PIN_GREEN, OUTPUT);
  pinMode(PIN_BLUE, OUTPUT);
  Serial.begin(9600);
}

void setColor(byte redbyte greenbyte blue) {
  analogWrite(PIN_RED, red);
  analogWrite(PIN_GREEN, green);
  analogWrite(PIN_BLUE, blue);
  Serial.print(red);
  Serial.print(":");
  Serial.print(green);
  Serial.print(":");
  Serial.println(blue);
}

void loop() {
  byte red = 0;
  byte green = 0;
  byte blue = 0;

  for(byte red = 0; red <= 255; red = min(255, red + AMOUNT_INCREASE)){
    for(byte green = 0; green <= 255; green = min(255, green + AMOUNT_INCREASE)){
      for(byte blue = 0; blue <= 255; blue = min(255, blue + AMOUNT_INCREASE)){
        setColor(red, green, blue);
        delay(DURATION_COLOR);

        if(blue == 255break;
      }
      if(green == 255break;
    }
    if(red == 255break;
  }
}


Photoresistors - The Photoconductive Cell - LDR - PGM5506 - Arduino Uno

 Require components:

1x PGM5506 

4x wires

1x LED 5mm

1x Resistor 10k

1x Resistor 200ohm




Code test:
void setup() {
  Serial.begin(9600);
}

void loop() {
  int value = analogRead(A0);
  Serial.println("Analog value : ");
  Serial.println(value);
  delay(200);
}

Code turn on LED when PGM5506 in low light:
const int PIN_LED = 9;
const int LIGHT_MIN = 350; // you may change this value to 0, depends on your environment
const int LIGHT_MAX = 750; // you may change this value to 1024, depends on your environment

void setup(){}

void loop() {
  int valueRead = analogRead(A0); // analogWrite values from 0 to 255, https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/
  byte valueWrite = 0;  // analogRead values go from 0 to 1023, https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/
  if(valueRead <= LIGHT_MIN) {
    valueWrite = 255;
  } else if(valueRead >= LIGHT_MAX) {
    valueWrite = 0;
  } else {
    valueWrite = map(valueRead, LIGHT_MIN, LIGHT_MAX, 2550);
  }
  analogWrite(PIN_LED, valueWrite);
  delay(100);
}