티스토리 뷰
커리큘럼
1.LED에 불 켜지게 하기
2.버튼 누르면 LED에 불 켜지게 하기
3.삼색 LED
4.거리 측정해서 LED불켜기
5.소리내기
6.조이스틱
- Variable : int x = analogInput()
- If, else if
7.pySerial
삼색 led
코드
#define RED 11
#define GREEN 10
#define BLUE 9
void setup() {
randomSeed(analogRead(0));
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(RED,random(255));
analogWrite(GREEN,random(255));
analogWrite(BLUE,random(255));
delay(2000);
}
초음파 센서로 색 바꾸기
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(11,0);
analogWrite(10,0);
analogWrite(9,0);
digitalWrite(2, HIGH);
delayMicroseconds(10);
digitalWrite(2, LOW);
long duration = pulseIn(3, HIGH);
if(duration == 0){
return;
}
long distance = duration / 58.2;
if(distance < 10){
analogWrite(11, 255);
} else if(distance < 20){
analogWrite(10, 100);
}else if(distance < 30){
analogWrite(9, 10);
}
delay(100);
}
void setup() {
// put your setup code here, to run once:
pinMode(7, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
tone(7, 523);
delay(1000);
tone(7, 587);
delay(1000);
}
사운드 센서
# define SOUND A0
# define BRIGHTNESS 50
int vol = 0;
int count = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(9,0);
analogWrite(10,0);
analogWrite(11,0);
vol = analogRead(A0);
if(vol > 55 and vol < 65){
analogWrite(10, BRIGHTNESS);
} else if(vol >= 65){
Serial.print("소리:" );
Serial.println(vol);
analogWrite(9, BRIGHTNESS);
}
delay(100);
}
4열 세그먼트 캐소드
pySerial
https://blog.naver.com/PostView.nhn?blogId=dokkosam&logNo=222084480691&from=search&redirect=Log&widgetTypeCall=true&directAccess=false
728x90
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 도커각티슈케이스
- 싱가폴
- 도커티슈케이스
- 도커컨테이너
- 이직
- docker container whale
- docker container tissue
- shellscript
- Sh
- 도커각티슈박스
- docker container case
- 개발자
- Linux
- 2017 티스토리 결산
- 도커티슈박스
- docker container
- docker container tissue box
- vim
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함