진동 센서 모듈(SW-18010P): 두 판 사이의 차이

아두위키 : Arduwiki
편집 요약 없음
잔글편집 요약 없음
 
65번째 줄: 65번째 줄:


* [https://gongzipsa.com/shop/1699939316 공집사몰]
* [https://gongzipsa.com/shop/1699939316 공집사몰]
* [https://smartstore.naver.com/gongzipsa/products/7526657232 공집사 스마트스토어]

2025년 3월 27일 (목) 15:30 기준 최신판

충격, 진동을 감지할 수 있는 모듈입니다.

디지털로 출력하는 모듈이며 아날로그 출력은 되지 않습니다.

사양

  • 작동 전압[V] : 3.3 ~ 5
  • 출력 : 디지털(아날로그 X)

예제 필요 하드웨어

연결

LED 진동센서 Arduino
VCC 5V
- GND GND
+ D7
DO D8

예제 코드

진동이 감지되면 LED가 켜지는 코드입니다.

int led = 7;
int sensor = 8;

void setup(){
  pinMode(led, OUTPUT);
  pinMode(sensor, INPUT);
  digitalWrite(led, LOW);
}

void loop(){
  int a = digitalRead(sensor);
  if(a==LOW) digitalWrite(led, HIGH);
  else digitalWrite(led,LOW);
}

실행결과

구매 링크