아두이노 코드 조명부 #include <Encoder.h> Encoder myEnc(3, 4); long oldPosition = -999; // 13번핀에 빨간색 LED를 연결합니다. int redPin = 9; // 12번핀에 노란색 LED를 연결합니다. int bluePin = 11; // 11번핀에 초록색 LED를 연결합니다. 로터리엔코더모듈센서부 int greenPin = 10; // 로터리 엔코더의 aPin을 4번핀에 연결합니다. int aPin = 4; // 로터리 엔코더의 bPIn을 3번핀에 연결합니다. int bPin = 3; // 로터리 엔코더의 푸시버튼을 2번핀에 연결합니다. int buttonPin = 5; // 현재 상태를 저장합니다. int state = 0; // 초록색이나 빨간색일 때 불이 들어오는 시간을 설정합니다. int longPeriod = 100; // 신호가 바뀔때의 시간을 설정합니다. int shortPeriod = 10; int targetCount = shortPeriod; int count = 0; void setup() { pinMode(aPin, INPUT); pinMode(bPin, INPUT); Serial.begin(9600); pinMode(buttonPin, INPUT_PULLUP); Serial.println(INPUT_PULLUP); pinMode(redPin, OUTPUT); pinMode(bluePin, OUTPUT); pinMode(greenPin, OUTPUT); } void loop() { count++; // 푸시버튼이 LOW일때 if (digitalRead(buttonPin)...



























댓글
댓글 쓰기