티스토리 뷰
디지털 푸쉬버튼 스위치
스위치로 사용할 수 있는 푸쉬버튼 모듈을 배워봅니다. 버튼을 누르고 있는 동안 신호가 바뀌어 ON/OFF 개념으로 사용할수 있습니다.
버튼을 누르는 동안 LOW 신호가 출력되며, 누르지 않을 때 HIGH 신호를 출력합니다.
구글 검색어..
<!--[if !supportEmptyParas]--> <!--[endif]-->
푸쉬버튼 디바운스
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
void setup(){
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
pinMode(13,OUTPUT)
pinMode(12,OUTPUT)
}
void loop(){
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
delay(50);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(50);
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
--------------------
1대9의 비율로 아날로그 출력을 하는 것
void loop(){
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
delay(1);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(9);
<!--[if !supportEmptyParas]--> <!--[endif]-->
컴퓨터로 출력할때 는 디지털이나 아날로그로 출력한것
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT)
pinMode(12, OUTPUT)
}
<!--[if !supportEmptyParas]--> <!--[endif]-->
void loop() {
// put your main code here, to run repeatedly:
analogWrite(13, 200);
analogWrite(10,50);
}
<!--[if !supportEmptyParas]--> <!--[endif]-->
디지털로 출력할때 digjtal Write
디지털 입력은 digitalRead는 1번부터 13번까지 모두
<!--[if !supportEmptyParas]--> <!--[endif]-->
---------------------------------------
<!--[if !supportEmptyParas]--> <!--[endif]-->
구글링 검색어
bounce
<!--[if !supportEmptyParas]--> <!--[endif]-->
http://deneb21.tistory.com/301참고
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
예제7
<!--[if !supportEmptyParas]--> <!--[endif]-->
아날로그는 a1부터 a7까지 있다.
<!--[if !supportEmptyParas]--> <!--[endif]-->
0V부터 5v의 사이는 0부터 1023사이의 정수값의 아날로그의 배열로 이루어져잇다.
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
http://mechasolution.com/shop/main/index.php
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
<!--[if !supportEmptyParas]--> <!--[endif]-->
적외선과 초음파는 거리에 관한 프로젝트 많이 씀..라인센서...
<!--[if !supportEmptyParas]--> <!--[endif]-->
자리로는 가속도를 쓸 때 많이 씀.
3축 자기장센서
샘플 코드
void setup() {
Serial.begin(9600); // 시리얼 통신을 시작, 통신속도는 (9600)
pinMode(3, INPUT); // 디지털 3번 핀을 입력모드로 설정
}
void loop() {
int a = digitalRead(3); // 정수형 변수 a를 생성한 후 디지털 3번핀에 입력되는 신호를 입력
if (a == HIGH) { // a가 HIGH (1)이면 (버튼을 누르지 않으면)
Serial.println("Do not press"); // 시리얼 모니터에 Do not press을 입력)
delay(2000); // 2초간 대기
}
else { // 그게 아니라면 (a가 HIGH가 아니라면) (버튼을 누르면)
Serial.println("Press down"); // 시리얼 모니터에 Press down을 입력
delay(2000); // 2초간 대기
}
}
튜토리얼
---------------------------------------------
void setup(){
pinMode(13,OUTPUT)
pinMode(12,OUTPUT)
}
void loop(){
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
delay(50);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(50);
--------------------
1대9의 비율로 아날로그 출력을 하는 것
void loop(){
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
delay(1);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(9);
컴퓨터로 출력할때 는 디지털이나 아날로그로 출력한것
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT)
pinMode(12, OUTPUT)
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(13, 200);
analogWrite(10,50);
}
디지털로 출력할때 digjtal Write
디지털 입력은 digitalRead는 1번부터 13번까지 모두
---------------------------------------
구글링 검색어
bounce
LED의 종류
부품(오프라인) ds-parts.co.kr http://robot.co.kr/
'팹랩메이커양성프로젝트' 카테고리의 다른 글
| 최종프로젝트준비과정1 (0) | 2017.11.22 |
|---|---|
| 14회차--아두이노 패러럴통신과 저항 (0) | 2017.11.10 |
| 제11회차--아두이노START_DC 모터, 서보 모터 (0) | 2017.11.01 |
| 제10회차--3D프린터 테스트 (0) | 2017.10.31 |
| 제10회차--레이저커트 (0) | 2017.10.30 |