배송 |
---|
상품 정보 | 가격 | 삭제 |
---|---|---|
[노크 센서 모듈 Grove Type] 아두이노 충격 감지 | ||
TOTAL PRICE(수량) 0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | const int tapSensorPin = 2; // 탭 센서의 핀을 2번에 연결 void setup() { Serial.begin(9600); // 시리얼 통신 시작 pinMode(tapSensorPin, INPUT); // 탭 센서 핀을 입력으로 설정 } void loop() { int tapSensorValue = digitalRead(tapSensorPin); // 탭 센서 값 읽기 if (tapSensorValue == HIGH) { // 탭이 감지되면 Serial.println("탭이 감지되었습니다!"); // 시리얼 모니터에 메시지 출력 } else { // 탭이 감지되지 않으면 Serial.println("탭이 감지되지 않았습니다."); // 시리얼 모니터에 메시지 출력 } delay(1000); // 1초 대기 } | cs |