사용자 도구

사이트 도구


commands:reference:ictud

문서의 이전 판입니다!


Ictud()

Ictud()는 증가 입력과 감소 입력을 하나의 카운터에서 처리합니다.

Ictud 명령어 동작 흐름

bool Ictud(uint8_t counter_id, bool CU, bool CD, bool RESET, bool LOAD, int32_t PV)

명령어

명령어 인수 반환값 동작
Ictud(counter_id, CU, CD, RESET, LOAD, PV) uint8_t counter_id — 카운터 번호. uint8_t 범위이므로 0 ~ 255 사용 가능
bool CU
bool CD
bool RESET
bool LOAD
int32_t PV — 설정값
bool 증가 입력과 감소 입력을 하나의 카운터에서 처리합니다.

예제

const uint8_t COUNTER_ID = 2;
const int32_t RACK_CAPACITY = 100;
 
void setup() {
  Serial.begin(115200);
}
 
void loop() {
  const bool entered = digitalRead(0) == HIGH;
  const bool exited = digitalRead(1) == HIGH;
  const bool reset = digitalRead(2) == HIGH;
  const bool preset = digitalRead(3) == HIGH;
  const bool full = Ictud(COUNTER_ID, entered, exited, reset, preset, RACK_CAPACITY);  // 증가 입력과 감소 입력을 하나의 카운터에서 처리합니다.
  digitalWrite(32, full ? HIGH : LOW);
}

주의사항

  • 기존 0~31 고정 제한은 제거되었다. 단, 인수 타입이 uint8_t이므로 최대 ID는 255이다.
  • 메모리가 부족해서 카운터 상태를 확보하지 못하면 카운터 명령어는 false 또는 0을 반환한다.
  • 한 번 생성된 카운터 상태는 프로그램 실행 중 유지된다.

같은 카테고리의 내장 명령어

commands/reference/ictud.1788796399.txt.gz · 마지막으로 수정됨: 저자 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki