Skip to content

Instantly share code, notes, and snippets.

@gitaeks
Created December 22, 2020 23:44
Show Gist options
  • Select an option

  • Save gitaeks/30168f82148a4d99581282088cb2205a to your computer and use it in GitHub Desktop.

Select an option

Save gitaeks/30168f82148a4d99581282088cb2205a to your computer and use it in GitHub Desktop.
chkMask
#include <Servo.h>
#include <Adafruit_NeoPixel.h>
#define PIXEL_PIN 4
#define PIXEL_COUNT 3 // 네오픽셀 수
int trigPin = 2; //초음파 트리거 핀
int echoPin = 3; //초음파 에코 핀
int infraredPin = 3;
Servo drawer; //서보모터 객체선언
Adafruit_NeoPixel ring (PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800); // 네오픽셀 객체선언
void setup() {
Serial.begin(9600); // 초음파 센서의 거리를 확인하기 위해 시리얼 통신을 시작
ring.begin(); // 네오픽셀 초기화
drawer.attach(6); //서보모터 초기화 핀번호
pinMode(trigPin,OUTPUT); 초음파 센서 초기화
pinMode(echoPin, INPUT);
}
void loop() {
//1.장애물 감지
motionState = digitalRead(MOTION);
if (motionState == HIGH) {
Serial.println("motion on");
drawer.write(180); //마스크수납 서랍 열기
} else {
Serial.println("motion off");
drawer.write(90); //마스크수납 서랍 닫기
}
//마스크 필요시 보관박스에 손을 내밀었을때 박스 하단 열기
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment