Forum

Notifications
Clear all

RGB LED

1 Posts
2 Users
0 Reactions
135 Views
0
Topic starter

OpenExo/issues/16#issue-3391419583

I used a multimeter to measure the RGB LED labeled '1 4' on the AK Board 0.5.1 11 silkscreen and found that its second pin is connected to the board's GND. After checking the Gerber files, I confirmed this connection is by design. This indicates a common-cathode RGB LED is used on the board. However, the component linked in our BOM list is a common-anode type ( https://www.digikey.com/en/products/detail/kingbright/WP154A4SEJ3VBDZGC-CA/7597097 ). I suspect there might be a mismatch?


1 Answer
0

Today I replaced it with a common cathode RGB LED and verified it with the refactored program. It works! I'm happy to share the refactored code with everyone.

/*
Code to test the Status LED on AK Board 0.5.1
Adapted for Teensy4.1
Based on OpenExo project
*/
#if defined(ARDUINO_TEENSY41) // 仅针对Teensy4.1编译
// 系统头文件
#include "src/Board.h"
#include "src/Utilities.h"
#include "src/ParseIni.h"
#include "src/Logger.h"

// 状态LED相关头文件
#include "src/StatusLed.h"
#include "src/StatusDefs.h"

namespace config_info {
uint8_t (config_to_send)[ini_config::number_of_keys];
}

// 定义要测试的状态消息列表(覆盖主要状态类型)
const uint16_t test_messages[] = {
status_defs::messages::off,
status_defs::messages::trial_off,
status_defs::messages::trial_on,
status_defs::messages::test,
status_defs::messages::torque_calibration,
status_defs::messages::fsr_calibration,
status_defs::messages::motor_start_up,
status_defs::messages::error,
status_defs::messages::warning
};
const uint8_t num_messages = sizeof(test_messages) / sizeof(test_messages[0]);

// 状态LED对象声明
StatusLed* status_led;

void setup() {
// 初始化串口通信
Serial.begin(115200);
while (!Serial); // 等待串口就绪

// 打印板型和硬件信息
#if BOARD_VERSION == AK_Board_V0_5_1
logger::println("Board : AK_Board_V0_5_1");
#elif BOARD_VERSION == AK_Board_V0_3
logger::println("Board : AK_Board_V0_3");
#elif BOARD_VERSION == AK_Board_V0_1
logger::println("Board : AK_Board_V0_1");
#else
logger::println("Board : Unknown Version");
#endif
logger::println("Teensy 4.1");

// 打印LED引脚配置
logger::print("Status LED Pins - R: ");
logger::print(logic_micro_pins::status_led_r_pin);
logger::print(", G: ");
logger::print(logic_micro_pins::status_led_g_pin);
logger::print(", B: ");
logger::println(logic_micro_pins::status_led_b_pin);

// 初始化状态LED(使用板级定义的引脚)
status_led = new StatusLed(
logic_micro_pins::status_led_r_pin,
logic_micro_pins::status_led_g_pin,
logic_micro_pins::status_led_b_pin,
2048 // 初始亮度(0-4095)
);

logger::println("Status LED test started. Cycling through states...");
}

void loop() {
static int current_idx = 0;
static unsigned long last_change = millis();
const unsigned long state_duration = 5000; // 每个状态持续5秒(原10秒缩短为5秒方便测试)

// 定时切换状态
if (millis() - last_change >= state_duration) {
current_idx = (current_idx + 1) % num_messages;
last_change = millis();

// 打印当前状态信息
logger::print("\nSwitching to state: ");
print_status_message(test_messages[current_idx]);
logger::print(" (ID: ");
logger::print(test_messages[current_idx]);
logger::println(")");
}

// 更新LED状态
status_led->update(test_messages[current_idx]);

// 小延迟避免占用过高CPU
delay(50);
}

#else
// 非Teensy4.1环境提示
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("This code is only compatible with Teensy4.1!");
}

void loop() {}
#endif

 


Your Answer

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved