광센서#
소개#
light 클래스는 물체에서 반사되거나 물체에 비치는 빛의 밝기를 측정하는 광 센서와 함께 사용됩니다. 감지된 빛의 양을 나타내는 아날로그 값을 출력합니다.

클래스 생성자#
light(
triport::port &port );
클래스 소멸자#
light 객체를 파괴하고 관련 리소스를 해제합니다.
virtual ~light();
매개변수#
매개변수 |
유형 |
설명 |
|---|---|---|
|
|
광센서가 연결된 3선 포트는 |
예시#
// Create a light instance in Port A
light LightA = light(Brain.ThreeWirePort.A);
회원 기능#
light 클래스는 다음과 같은 멤버 함수를 포함합니다.
brightness— 광 센서가 감지한 빛의 양을 반환합니다.
light 멤버 함수를 호출하기 전에 아래와 같이 light 인스턴스를 생성해야 합니다.
/* This constructor is required when using VS Code.
Light Sensor configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create a light instance in Port A
light LightA = light(Brain.ThreeWirePort.A);
brightness#
광 센서가 감지한 빛의 양을 반환합니다. 이 값은 물체가 다른 시각 데이터를 정확하게 보고할 만큼 충분히 밝은지 확인하는 데 사용할 수 있습니다.
Available Functionsint32_t brightness(
percentUnits units = percentUnits::pct );
매개변수 |
유형 |
설명 |
|---|---|---|
|
|
밝기를 나타내는 단위: |
광 센서가 측정한 밝기를 0~100% 범위의 백분율로 나타내는 int32_t 값을 반환합니다.
// Get Light Sensor brightness in range of 0% - 100%.
int32_t value = LightA.brightness();
// Print the brightness of the Light Sensor to the
// Brain's screen.
Brain.Screen.print(value);