Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- PyQt5
- VS Code
- flask
- 성능지표
- DB 데이터
- DB 데이터 저장
- #endif
- bootstrap4 패키지
- #else
- MySQL 세팅
- #undef
- href
- #ifndef
- openweathermap
- 콘솔 가상환경 # 콘솔 #가상환경
- OpenCV + Flask
- jinja2
- 명령어
- heroku
- 튜토리얼
- OpenCV
- bootstrap
- 환경변수 설정
- 사이트 도메인
- #if
- javascript
- Django
- 실시간 시계
- #ifdef
- Action
Archives
- Today
- Total
PROGRAMMING
실습 - 버튼, LED, PIR, PWM, 초음파, 온습도 본문
◎ LED, LED(BUTTON)
◎ RGB_LED
◎ PIR_SENSOR
◎ SENSOR (ARDUINO CODE)
• SENSOR arduino code
int buttonState = 0;
int lastButtonState = 0;
int buttonPushCounter = 0;
void setup()
{
pinMode(2, INPUT);
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
// read the pushbutton input pin
buttonState = digitalRead(2);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH, then the button
// went from off to on
buttonPushCounter += 1;
Serial.println("on");
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter);
} else {
// if the current state is LOW, then the button
// went from on to off
Serial.println("off");
}
// delay a little bit to avoid debouncing
delay(5); // Wait for 5 millisecond(s)
}
// save the current state as the last state, for
// the next time through the loop
lastButtonState = buttonState;
// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the devision of two numbers
if (buttonPushCounter % 4 == 0) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
}
◎ PWM
◎ 초음파 센서
◎ 온습도 센서
'Raspberry' 카테고리의 다른 글
실습 파일(I2C LCD, I2C_LCD_driver.py 포함) (0) | 2020.11.03 |
---|---|
My Note (0) | 2020.11.03 |
라즈베리 관련 명령어 (0) | 2020.11.03 |
I2C LCD - 참고 사이트 (0) | 2020.11.03 |
Comments