Friday, August 28, 2026

Cocos Creator 2 Inspector

 # Cocos Creator Inspector 2.4

The extension provides a Hierarchy view for browsing the active node tree of a running Cocos Creator game.

You can inspect nodes, expand and collapse branches, search by name, and filter by useful runtime categories such as components, renderable nodes, text-related components, animation, UI interaction, masking, particles, sprites, Spine content, and other common scene objects.

Chrome Web Store: https://chromewebstore.google.com/detail/cocos-creator-inspector-2/omldaloggokfpiciomplbnebkcfiecic


## Inspect the live scene hierarchy

The extension provides a Hierarchy view for browsing the active node tree of a running Cocos Creator game.

You can inspect nodes, expand and collapse branches, search by name, and filter by useful runtime categories such as components, renderable nodes, `cc.Animation`, `cc.BlockInputEvents`, `cc.Button/cc.Toggle`, `cc.EditBox`, `cc.Label`, `cc.Mask`, `cc.MotionStreak`, `cc.ParticleSystem`, `cc.RichText`, `cc.Sprite`, and `sp.Skeleton` nodes.


### Hierarchy nodes

The Hierarchy panel is designed to stay close to the way Cocos Creator developers already think about scenes. It shows the runtime node tree, not just static editor data, so you can inspect what is actually loaded in the browser.

Nodes can show useful visual states such as active, inactive, transparent, renderable, and component-related information. When a node is selected, the Inspector updates with live data from that node.

You can use the Hierarchy to quickly check:

- Node name and nesting.

- Parent and child relationships.

- Whether a node is active or inactive.

- Whether a node is visible or effectively hidden.

- Whether a node has render-related components.

- Whether a node contains common interactive components such as Button or Toggle.


### Hierarchy search and filters

The search box can filter the current runtime hierarchy without forcing a full scene reload.

Useful filters include:

- All nodes.

- Node name, path, UUID, and type search.

- Component and renderable-node search.

- Text-related component filters, animation, sprite, particle, masking, Spine, and UI interaction categories.

This is useful when a scene has hundreds or thousands of nodes and you only need to find one specific runtime object.

This makes it easier to answer common debugging questions:

- Is this node active?

- Is it visible?

- Is its parent disabled?

- Does it have the component I expect?

- Is it actually present in the loaded scene?


## View node and component details

Selecting a node shows detailed runtime information in the Inspector panel, including node properties, components, references, events, world scale, world size, and other useful data.

This is especially helpful when debugging UI behavior, broken references, wrong component values, or runtime changes that are difficult to see from the editor alone.


### Node and component inspection

The Inspector can show `cc.Node` values, built-in Cocos components, custom script components, prefab metadata, references, assets, arrays, vector values, color values, and selected runtime metadata.

For supported fields, values can be edited directly from the panel. Input editboxes support arithmetic calculation on Enter or blur (e.g. `10 + 20`), mouse-wheel delta stepping, and Esc to reset. The Inspector layout enforces a fixed-width, right-aligned value column ensuring that all inputs remain perfectly aligned regardless of group nesting level or indentation depth. Changed values can be highlighted with a Cocos Creator-style color, making it easier to compare runtime values against defaults.

Reference fields are shown as compact cards. You can see the reference type and target name, clear supported references, and hover a reference to highlight the matching node in the Hierarchy. Supported component summaries, assets, and debug sections include a `⧉ Var` button to store runtime objects into browser console global variables (`temp1`, `temp2`, ...).

Event handler rows are shown closer to Cocos Creator's workflow: target references are displayed as reference cards, while component and handler fields use dropdowns when the runtime can provide the available choices.

Sprite-related assets are displayed with clearer reference cards, including SpriteFrame and Atlas information when it can be resolved from the running game.

The Assets view can inspect runtime assets directly, including SpriteFrame previews, audio playback previews (with interactive waveform and seek), editable JsonAsset text, font previews, and a read-only `cc.ParticleAsset` Preview that follows the same field layout as a `cc.ParticleSystem` component. BitmapFont assets can show glyph details from the runtime font dictionary, with searchable glyph tables and a transposed view for compact inspection. Supported assets can also expose Download groups for their source files and matching metadata files, including ParticleAsset plist/texture files and EffectAsset source/meta files. Asset identities render before expensive preview and Inspector data, selection is restored after Reload Frame, and an off-screen selected asset has a clickable dock at the relevant table edge.

Related Inspector rows can collapse into focused groups when a field controls additional options. This keeps common rows compact while still exposing dependent settings when they matter, and the panel remembers manual expand or collapse choices across node changes.


### Useful Inspector details

The Inspector is helpful for checking:

- Node active state.

- Position, rotation, scale, anchor, size, color, opacity, skew, and group.

- Built-in components such as Canvas, Widget, Sprite, Camera, Label, Button, Toggle, Layout, Mask, ScrollView-related components, Slider, PageView, VideoPlayer, Light, MeshRenderer, ParticleSystem, Animation, and more.

- Prefab metadata such as prefab UUID, sync state, file id, root path, optimization policy, and async-load flag when available at runtime.

- Custom component properties.

- Node Info such as path, world position, world rotation, world scale, world size, and world opacity.

- Registered Events when enabled from settings.


## Debug layout and bounds visually

Cocos Creator Inspector 2.4 includes visual overlay tools for checking node bounds, canvas bounds, parent bounds, render canvas bounds, and hover rectangles.

These overlays help diagnose UI layout issues such as incorrect anchors, unexpected scaling, invisible nodes, zero-size containers, or elements that are positioned correctly but rendered outside the expected area.

Canvas, parent, and render-canvas measurements use separate colors, making it easier to compare a selected node against the scene canvas, its parent, and the actual browser render area. Zero-size nodes are still measurable, so container nodes and marker nodes can be inspected without flooding the screen with confusing duplicate labels.


## Test devices and preview settings

The toolbar includes device and runtime controls for changing preview size, an editable `% Canvas` scale control, orientation, mobile/desktop mode, FPS display, FPS limit, pause/resume, time scale, physics debug draw, collision debug draw, recompile behavior, dark/light theme mode, and Canvas/Page PNG capture.

You can also define custom device presets and choose how the extension restores device settings between reloads.


### Preview toolbar

The preview toolbar helps test browser builds without constantly changing the project or editor preview settings.

It includes:

- Device presets.

- Custom width and height.

- Editable `% Canvas` preview scale.

- Aspect ratio display.

- Canvas and Page PNG capture.

- Mobile/Desktop mode.

- Portrait/Landscape rotation.

- Pause/Resume.

- Time scale.

- Physics debug draw.

- Collision debug draw.

- Recompile.

- FPS display.

- FPS limit.

- Dark/Light theme toggle.

The toolbar can apply runtime preview changes through Cocos public APIs where available, while avoiding unsafe preview resizing for non-local remote pages.


## Customize the inspector

Cocos Creator Inspector 2.4 includes settings for toolbar items, hierarchy colors, selected and hovered node styles, inactive node colors, Inspector row spacing, component title colors, changed-value highlighting, reference colors, and dark or light theme mode.

These settings make it easier to match the panel to your debugging workflow and keep important runtime differences visible while inspecting complex scenes.


### Settings sections

The Settings panel is split into focused sections:

- Assets: asset list columns, thumbnails, refresh behavior, and component-specific previews, downloads, and metadata versions.

- AudioEngine: live music/effect volume, playback, active-audio state, and AudioClip selection.

- Capture: batch Canvas or Page screenshots, image scale, grid/item viewing, and download controls.

- General: theme mode and text scale.

- Hierarchy: icons, attached nodes, auto reload, expansion behavior, node colors, selected/hovered node colors, hover border width, and measurement overlay colors.

- Inspector: row spacing, dependency group layout, changed-value highlighting, `cc.Node` buttons, component actions, custom component options, title colors, value colors, `cc.Prefab`, Node Info, Registered Events, and messages.

- Toolbar: show or hide individual top bar items in the same order they appear on the toolbar.

- Devices: choose the default device behavior, manage custom devices, and reset device presets.

- Local Storage: view, edit, create, refresh, and delete Local Storage entries for the inspected frame.

- Iframes: inspect frames that may contain the Cocos runtime.

- DevTools Frames: choose the correct DevTools frame target when a page has multiple frames.


### Hotkeys

The Hierarchy supports keyboard shortcuts for common navigation and editing actions.

Useful shortcuts include:

- Arrow Up / Arrow Down: move selection.

- Arrow Left / Arrow Right: collapse or expand nodes.

- F2: rename the selected node.

- Insert: duplicate the selected node.

- Delete: delete the selected node.

These shortcuts make the Hierarchy feel closer to a lightweight runtime editor while staying inside Chrome DevTools.


### Lightweight package

The build package is intentionally small. The current `0.6.0` zipped package is about `190 KiB`.

Keeping the package compact makes the extension easier to inspect, upload, and maintain.


### Lower memory and CPU overhead

Cocos Creator Inspector 2.4 is designed to stay lightweight while DevTools is open.

The extension avoids unnecessary always-on work where possible. Hierarchy refresh, selected-node inspection, toolbar synchronization, and settings rendering are scoped to the active panel or the selected runtime object instead of repeatedly scanning everything in the scene.

This helps reduce memory footprint and CPU usage during long debugging sessions, especially on large Cocos Creator scenes with many nodes and components.


## Work with iframes and DevTools frames

Many Cocos Creator web games run inside iframes or nested frames. The extension includes tools for inspecting available frames and selecting the correct Cocos runtime target.

This helps avoid guessing which frame contains the active `cc` runtime.


## Built for Cocos Creator 2.x workflows

Cocos Creator Inspector 2.4 is designed for developers who work directly with Cocos Creator 2.x browser builds and need a faster way to inspect runtime state.

It is useful for:

- UI debugging

- Scene hierarchy inspection

- Component and property checking

- Device preview testing

- Runtime layout verification

- Changed-value inspection

- Local Storage inspection

- Frame and iframe debugging


## Privacy Policy for Cocos Creator 2 Inspector

Effective date: September 30, 2026

Cocos Creator 2 Inspector is a Chrome DevTools extension that helps developers inspect and debug Cocos Creator 2 web games.

The extension runs inside Chrome DevTools and reads runtime information from the currently inspected page when the user opens and uses the `cci-2.4` panel.

When the user explicitly requests a Page capture, the extension uses the active inspected tab and host access to create a PNG locally. Canvas and Page screenshots remain in the extension panel until the user downloads or clears them.

It does not collect, sell, or share personal data.

It does not send inspected game data, scene data, local storage values, or runtime information to an external server.

Any settings saved by the extension are stored locally in the browser.


## How to use

Install the extension from the Chrome Web Store, open a Cocos Creator 2.x web game in Chrome, open DevTools, and select the `cci-2.4` panel.

From there, you can inspect the live scene, select nodes, view component data, adjust preview settings, and debug the running game directly from DevTools.

Cocos Creator Inspector 2.4 brings the runtime scene closer to where debugging already happens: the browser.


## Version history

- `0.6.0` — September 30, 2026: Added Canvas/Page screenshot capture, AudioEngine controls, progressive Assets loading and selection restoration, asset edge docking, expanded asset previews/downloads, and associated Settings controls.

- `0.5.5` — September 22, 2026: Released with Inspector layout refinements, collapsible dependency groups, saved group expand/collapse behavior across node changes, and additional spacing/style consistency fixes.

- `0.5.0` — September 21, 2026: Released with Inspector serialization fixes for common Cocos value types, improved EventHandler dropdowns, expanded Hierarchy filters, and clearer Sprite asset reference display.

- `0.4.0` — September 17, 2026: Released on the Chrome Web Store with Hierarchy filter updates, prefab metadata display, prefab-aware Hierarchy tooltips, and Inspector additional-information settings.

- `0.3.0` — September 10, 2026: First documented release in the public version history.


## Contact

If you have questions about this privacy policy, contact:

zXcongducXz@gmail.com



## Screenshots


















Saturday, August 22, 2026

GPX Fixer

I’ve built a web app that lets you view and edit GPX files with GPS errors; it currently supports Strava, and I’d appreciate your support. Step 1: Open the activity with the error, tap "...", and select "Export GPX".
Step 2: https://zxcongducxz.blogspot.com/p/gpx-fixer.html. Step 3: Click the "Choose file" button to upload the GPX file.
Step 4: Try making edits using the buttons below—it's quite simple. If you don't know what to fix, click the "Fastest" button, then the "Reshape" button, and repeat the process a few times until there are no remaining errors. Typically, after adjustments, the total distance decreases by a few hundred meters or a few kilometers.
Step 5: After editing, click the "Next" button in the top-right corner.
Step 6: Click the button to download the GPX file.
Step 7: Go to the Strava file upload page and click the "Choose file" button to upload the modified GPX file. https://www.strava.com/upload/select

Thursday, March 19, 2026

First time being hacked, lost facebook account and yahoo mail

 I've got email:

from johnblue@hola.com at 03/03/2026



 from johngreen67947@gmail.com at 17/03/2026 at trash mail, with his binance wallet: 18BERmDVpK1G9ttA7nUWUM3tcNCMY4BiNL


then my facebook transfer to account hollisterdarmiento6899@hotmail.com



it's really sorry that i don't use balance, don't have much money, and don't want to give you anything







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 duration, byte 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 duration, int 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 duration, float 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 duration, int number, byte 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 duration, float number, byte 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 duration, byte hours, byte 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 duration, byte 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 duration, byte data[], byte animationLength, byte 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 delayMove, byte 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 red, byte yellow, byte 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(255, 0, 0); delay(1000); // red
  setColor(0, 255, 0); delay(1000); // yellow
  setColor(0, 0, 255); delay(1000); // green
}

void show2LEDs() {
  Serial.println("show2LEDs()");
  setColor(255, 255, 0); delay(1000); // red & yellow
  setColor(0, 255, 255); delay(1000); // yellow & green
  setColor(255, 0, 255); delay(1000); // red & green
}

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

void fadeColor(byte red, byte yellow, byte 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(0, 0, 0);
  delay(100);
}

void fade1LED() {
  Serial.println("fade1LED()");
  fadeColor(255, 0, 0); delay(1000); // red
  fadeColor(0, 255, 0); delay(1000); // yellow
  fadeColor(0, 0, 255); delay(1000); // green
}

void fade2LEDs() {
  Serial.println("fade2LEDs()");
  fadeColor(255, 255, 0); delay(1000); // red & yellow
  fadeColor(0, 255, 255); delay(1000); // yellow & green
  fadeColor(255, 0, 255); delay(1000); // red & green
}

void fade3LEDs() {
  Serial.println("fade3LEDs()");
  fadeColor(0, 0, 0); delay(1000);       // turn off
  fadeColor(255, 255, 255); delay(1000); // turn on all colors
  fadeColor(0, 0, 0); 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();
}