슬라이드 1

Similar documents
Microsoft PowerPoint - es-arduino-lecture-03

Motor

Microsoft PowerPoint - ch03ysk2012.ppt [호환 모드]

PowerChute Personal Edition v3.1.0 에이전트 사용 설명서

K&R2 Reference Manual 번역본

Page 2 of 6 Here are the rules for conjugating Whether (or not) and If when using a Descriptive Verb. The only difference here from Action Verbs is wh


Page 2 of 5 아니다 means to not be, and is therefore the opposite of 이다. While English simply turns words like to be or to exist negative by adding not,

슬라이드 1

step 1-1

Slide 1

슬라이드 1

비어 있음

PowerPoint 프레젠테이션

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

2 min 응용 말하기 01 I set my alarm for It goes off. 03 It doesn t go off. 04 I sleep in. 05 I make my bed. 06 I brush my teeth. 07 I take a shower.

PowerPoint 프레젠테이션

Microsoft PowerPoint - es-arduino-lecture-08

13주-14주proc.PDF

MPLAB C18 C

<B3EDB9AEC1FD5F3235C1FD2E687770>

untitled

강의10

[ 영어영문학 ] 제 55 권 4 호 (2010) ( ) ( ) ( ) 1) Kyuchul Yoon, Ji-Yeon Oh & Sang-Cheol Ahn. Teaching English prosody through English poems with clon

휠세미나3 ver0.4

PRO1_09E [읽기 전용]

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

Something that can be seen, touched or otherwise sensed

RVC Robot Vaccum Cleaner

서강대학교 기초과학연구소대학중점연구소 심포지엄기초과학연구소

BC6DX Korean.ai

Interactive Workshop for Artists & Designers 연세대학교디지털아트학과, 2016 Earl Park

airDACManualOnline_Kor.key

BC6DX-II Korean.ai

untitled

hd1300_k_v1r2_Final_.PDF

PowerPoint 프레젠테이션

SRC PLUS 제어기 MANUAL

DIB-100_K(90x120)

Stage 2 First Phonics

BC6HP Korean.ai

PowerPoint 프레젠테이션

2

KT AI MAKERS KIT 사용설명서 (Node JS 편).indd

PRO1_04E [읽기 전용]

PowerPoint 프레젠테이션

목차 제 1 장 inexio Touch Driver소개 소개 및 주요 기능 제품사양... 4 제 2 장 설치 및 실행 설치 시 주의사항 설치 권고 사양 프로그램 설치 하드웨

<35335FBCDBC7D1C1A42DB8E2B8AEBDBAC5CDC0C720C0FCB1E2C0FB20C6AFBCBA20BAD0BCAE2E687770>

T100MD+

<31372DB9CCB7A1C1F6C7E22E687770>

歯9장.PDF

0125_ 워크샵 발표자료_완성.key

Coriolis.hwp

DC Link Application DC Link capacitor can be universally used for the assembly of low inductance DC buffer circuits and DC filtering, smoothing. They

C++-¿Ïº®Çؼ³10Àå


untitled

< C6AFC1FD28B1C7C7F5C1DF292E687770>

LCD Display

사용시 기본적인 주의사항 경고 : 전기 기구를 사용할 때는 다음의 기본적인 주의 사항을 반드시 유의하여야 합니다..제품을 사용하기 전에 반드시 사용법을 정독하십시오. 2.물과 가까운 곳, 욕실이나 부엌 그리고 수영장 같은 곳에서 제품을 사용하지 마십시오. 3.이 제품은

슬라이드 제목 없음

MAX+plus II Getting Started - 무작정따라하기

MAGIC-6004M_K

Microsoft Word - SRA-Series Manual.doc

PWR PWR HDD HDD USB USB Quick Network Setup Guide xdsl/cable Modem PC DVR 1~3 1.. DVR DVR IP xdsl Cable xdsl Cable PC PC DDNS (

untitled

슬라이드 1

<3130C0E5>

H3050(aap)

,,,,,, (41) ( e f f e c t ), ( c u r r e n t ) ( p o t e n t i a l difference),, ( r e s i s t a n c e ) 2,,,,,,,, (41), (42) (42) ( 41) (Ohm s law),


CD-RW_Advanced.PDF

PowerPoint 프레젠테이션

Journal of Educational Innovation Research 2019, Vol. 29, No. 1, pp DOI: (LiD) - - * Way to

(specifications) 3 ~ 10 (introduction) 11 (storage bin) 11 (legs) 11 (important operating requirements) 11 (location selection) 12 (storage bin) 12 (i

ApplicationKorean.PDF

- 2 -

DBPIA-NURIMEDIA

< C6AFC1FD28C3E0B1B8292E687770>

example code are examined in this stage The low pressure pressurizer reactor trip module of the Plant Protection System was programmed as subject for

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

Microsoft PowerPoint - Java7.pptx

02 C h a p t e r Java

ez-md+_manual01

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202834C1D6C2F7207E2038C1D6C2F729>

07 자바의 다양한 클래스.key

DTS-L300-V2 Specification Page 1 of 14 비접촉온도측정 원거리온도측정 High Accuracy Digital Interface : SPI Arduino UNO 예제코드제공 제품설명 DTS-L300-V2는접촉을하지않고원하는물체표면에온도를 50

chap10.PDF

한글사용설명서

1. Features IR-Compact non-contact infrared thermometer measures the infrared wavelength emitted from the target spot and converts it to standard curr

C프로-3장c03逞풚

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202834C1D6C2F7207E2038C1D6C2F729>

슬라이드 1

INDUCTION MOTOR 표지.gul

04-다시_고속철도61~80p

10주차.key


SIGPLwinterschool2012

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

Transcription:

임베디드시스템개론 : Arduino 활용 Lecture #7: Piezzo Buzzer & Flex Sensor 활용 2012. 4. 27 by 김영주

강의목차 Piezzo Buzzer 개요 Tone 출력실험 Piezzo Sensor 실험 Flex Sensor 개요 Flex Sensor 활용실험 2

Piezzo Buzzer (1) 개요 Piezzo Buzzers Piezoelectonics piezein is greek for squeeze Some crystals, when squeezed, make a spark Spark a quartz crystal, and it flexes Piezo buzzers use this to make sound flex something back and forth, it moves air Piezo buzzers don t have quartz crystals, but instead a kind of ceramic that also exhibits piezoelectric properties Two wires, red & black 극성 : black=ground Apply an oscillating voltage to make a noise The buzzer case supports the piezzo element and has resonant cavity for sound 3

Piezzo Buzzer (2) 개요 Piezzo Buzzers Piezzo element 흰색디스크 인가되는전압이진동하면디스크가진동하여소리를생성역으로디스크를진동하면전압이생성 센서로활용 4

멜로디출력실험 (1) 실험개요 Piezzo buzzer 를이용하여기본적인멜로디를출력한다. 출력할계명을모니터에서문자로입력받고, 해당된계명을출력하도록한다. 사전요구사항 Piezzo buzzer 의동작원리를이해한다. 계명별로고유의주파수를가지며, 이를이용하여음을생성하는방법을이해한다. 5

멜로디출력실험 (2) 회로구성 6

멜로디출력실험 (3) 아두이노프로그램 멜로디출력 7 /* Melody * This example uses a piezo speaker to play melodies. It sends * a square wave of the appropriate frequency to the piezo, generating * the corresponding tone. * * The calculation of the tones is made following the mathematical * operation: timehigh = period / 2 = 1 / (2 * tonefrequency) * where the different tones are described as in the table: * * note frequency period timehigh * c 261 Hz 3830 1915 * d 294 Hz 3400 1700 * e 329 Hz 3038 1519 * f 349 Hz 2864 1432 * g 392 Hz 2550 1275 * a 440 Hz 2272 1136 * b 493 Hz 2028 1014 * C 523 Hz 1912 956 * * http://www.arduino.cc/en/tutorial/melody */

멜로디출력실험 (4) 아두이노프로그램 멜로디출력 int speakerpin = 7; int length = 8; // the number of notes char notes[] = "cdefgabc "; // a space represents a rest int tempo = 300; Int serbyte; void playtone(int tone, int duration) { for (long i = 0; i < duration * 1000L; i += tone * 2) { digitalwrite(speakerpin, HIGH); delaymicroseconds(tone); digitalwrite(speakerpin, LOW); delaymicroseconds(tone); void playnote(char note, int duration) { static char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' ; static int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 ; 8 // play the tone corresponding to the note name for (int i = 0; i < 8; i++) { if (names[i] == note) { playtone(tones[i], duration); break;

멜로디출력실험 (5) 아두이노프로그램 멜로디출력 void setup() { Serial.begin(115200); pinmode(speakerpin, OUTPUT); for (int i = 0; i < length; i++) { playnote(notes[i], tempo); void loop() { while (Serial.available()) { serbyte = Serial.read(); playnote(serbyte, tempo); Serial.print(serByte); 9

멜로디출력실험 (6) 실험결과 소리크기조정 소리크기줄이기 10

멜로디출력실험 (7) 실험개요 저장되어있는멜로디를 Piezzo buzzer 를이용하여출력한다. 11

멜로디출력실험 (8) 아두이노프로그램 저장멜로디출력 int ledpin = 13; int speakerout = 7; byte names[] = {'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C'; int tones[] = {1915, 1700, 1519, 1432, 1275, 1136, 1014, 956; byte melody[] = "2d2a1f2c2d2a2d2c2f2d2a2c2d2a1f2c2d2a2a2g2p8p8p8p"; // count length: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 // 10 20 30 int count = 0; int count2 = 0; int count3 = 0; int MAX_COUNT = 24; int statepin = LOW; void setup() { pinmode(ledpin, OUTPUT); 12 void loop() { analogwrite(speakerout, 0); for (count = 0; count < MAX_COUNT; count++) { statepin =!statepin; digitalwrite(ledpin, statepin);

멜로디출력실험 (9) 아두이노프로그램 저장멜로디출력 for (count3 = 0; count3 <= (melody[count*2] - 48) * 30; count3++) { for (count2=0;count2<8;count2++) { if (names[count2] == melody[count*2 + 1]) { analogwrite(speakerout,500); delaymicroseconds(tones[count2]); analogwrite(speakerout, 0); delaymicroseconds(tones[count2]); if (melody[count*2 + 1] == 'p') { // make a pause of a certain size analogwrite(speakerout, 0); delaymicroseconds(500); 13

Arduino Tone Library (1) Arduino Tone Library Arduino core에서 tone 출력기능지원 tone(pin, frequency, duration) notone(pin) 임의의 pin으로지정된주파수의 square-wave pulse (50% duty cycle) 를생성 펄스생성시간은지정가능 출력pin에는 piezo buzzer 또는다른스피커를연결하면소리가생성 RTTTL (RingTone Text Transfer Language) 플레이가능 14

Arduino Tone Library (2) Tone 함수를이용한멜로디출력 (1) 회로구성 15

Arduino Tone Library (3) Tone 함수를이용한멜로디출력 (2) 아두이노프로그램 /* Melody : Plays a melody circuit: 8-ohm speaker on digital pin 8 http://arduino.cc/en/tutorial/tone */ #include "pitches.h" // notes in the melody: int melody[] = { NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4; // note durations: 4 = quarter note, 8 = eighth note, etc.: int notedurations[] = { 4, 8, 8, 4,4,4,4,4 ; void setup() { // iterate over the notes of the melody: for (int thisnote = 0; thisnote < 8; thisnote++) { 16 // to calculate the note duration, take one second divided by the note type. // e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteduration = 1000/noteDurations[thisNote]; tone(8, melody[thisnote],noteduration);

Arduino Tone Library (4) Tone 함수를이용한멜로디출력 (3) 아두이노프로그램 // to distinguish the notes, set a minimum time between them. // the note's duration + 30% seems to work well: int pausebetweennotes = noteduration * 1.30; delay(pausebetweennotes); // stop the tone playing: notone(8); void loop() { // no need to repeat the melody. 17

Arduino Tone Library (5) 센서입력에의한톤출력 (1) 회로구성 18

Arduino Tone Library (6) 센서입력에의한톤출력 (2) 아두이노프로그램 void setup() { // nothing to do here void loop() { // get a sensor reading: int sensorreading = analogread(a0); // map the results from the sensor reading's range // to the desired pitch range: float frequency = map(sensorreading, 200, 900, 100, 1000); // change the pitch, play for 10 ms: tone(8, frequency, 10); 19

Arduino Tone Library (7) RTTTL Player (1) RTTTL(RingTone Text Transfer Language) http://en.wikipedia.org/wiki/ring_tone_transfer_language RTTTL Player 회로구성 회로구성은앞실험과동일 20

Arduino Tone Library (8) RTTTL Player (2) 아두이노프로그램 21 /************************************************* * pitch.h : Public Constants *************************************************/ #define NOTE_B0 31 #define NOTE_C1 33 #define NOTE_CS1 35 #define NOTE_D1 37 #define NOTE_DS1 39 #define NOTE_E1 41 #define NOTE_F1 44 #define NOTE_FS1 46 #define NOTE_G1 49 #define NOTE_GS1 52 #define NOTE_A1 55 #define NOTE_AS1 58 #define NOTE_B1 62 #define NOTE_C2 65 : : :

Arduino Tone Library (9) RTTTL Player (3) 아두이노프로그램 #include "pitches.h #define OCTAVE_OFFSET 0 int notes[] = { 0, NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_DS4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4, NOTE_AS4, NOTE_B4, NOTE_C5, NOTE_CS5, NOTE_D5, NOTE_DS5, NOTE_E5, NOTE_F5, NOTE_FS5, NOTE_G5, NOTE_GS5, NOTE_A5, NOTE_AS5, NOTE_B5, NOTE_C6, NOTE_CS6, NOTE_D6, NOTE_DS6, NOTE_E6, NOTE_F6, NOTE_FS6, NOTE_G6, NOTE_GS6, NOTE_A6, NOTE_AS6, NOTE_B6, NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7 ; 22 //char *song = "The Simpsons:d=4,o=5,b=160:c.6,e6,f#6,8a6,g.6,e6,c6,8a,8f#,8f#,8f#,2g,8p,8p,8f#,8f#,8f#,8g,a#.,8c6,8c6,8c6,c6"; //char *song = "Indiana:d=4,o=5,b=250:e,8p,8f,8g,8p,1c6,8p.,d,8p,8e,1f,p.,g,8p,8a,8b,8p,1f6,p,a,8p,8b,2c6,2d6,2e6,e,8p,8f,8g,8p,1c6,p,d6,8p,8e6,1f.6,g,8p,8g,e.6,8p,d6, 8p,8g,e.6,8p,d6,8p,8g,f.6,8p,e6,8p,8d6,2c6"; //char *song = "TakeOnMe:d=4,o=4,b=160:8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5, 8e5,8f#5,8e5,8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5"; //char *song = "Entertainer:d=4,o=5,b=140:8d,8d#,8e,c6,8e,c6,8e,2c.6,8c6,8d6,8d#6,8e6,8c6,8d6,e6,8b,d6,2c6,p,8d,8d#,8e,c6,8e,c6,8e,2c.6,8p,8a,8g,8f#,8a,8c6,e6,8 d6,8c6,8a,2d6"; //char *song = "Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,8e,8p,8e,g,2p,c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c 6,8c,8d,e,8e,d,8d,c ;

Arduino Tone Library (10) RTTTL Player (4) 아두이노프로그램 23 char *song = "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,e6,2b."; //char *song = "Looney:d=4,o=5,b=140:32p,c6,8f6,8e6,8d6,8c6,a.,8c6,8f6,8e6,8d6,8d#6,e.6,8e6,8e6,8c6,8d6,8c6,8e6,8c6,8d6,8a,8c6,8g,8a#,8a,8f"; //char *song = "20thCenFox:d=16,o=5,b=140:b,8p,b,b,2b,p,c6,32p,b,32p,c6,32p,b,32p,c6,32p,b,8p,b,b,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,g#,32p,a,32p,b,8p,b, b,2b,4p,8e,8g#,8b,1c#6,8f#,8a,8c#6,1e6,8a,8c#6,8e6,1e6,8b,8g#,8a,2b"; //char *song = "Bond:d=4,o=5,b=80:32p,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d#6,16d#6,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d6,16c#6,16c#7,c.7,16g#6,16f#6,g#.6"; //char *song = "MASH:d=8,o=5,b=140:4a,4g,f#,g,p,f#,p,g,p,f#,p,2e.,p,f#,e,4f#,e,f#,p,e,p,4d.,p,f#,4e,d,e,p,d,p,e,p,d,p,2c#.,p,d,c#,4d,c#,d,p,e,p,4f#,p,a,p,4b,a,b,p,a,p,b,p,2 a.,4p,a,b,a,4b,a,b,p,2a.,a,4f#,a,b,p,d6,p,4e.6,d6,b,p,a,p,2b"; //char *song = "StarWars:d=4,o=5,b=45:32p,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#.6,32f#,32 f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#6"; //char *song = "GoodBad:d=4,o=5,b=56:32p,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,d#,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,c#6,32a#,32d#6,32a#,32d#6,8a #.,16f#.,32f.,32d#.,c#,32a#,32d#6,32a#,32d#6,8a#.,16g#.,d#"; //char *song = "TopGun:d=4,o=4,b=31:32p,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,16f,d#,16c#,16g#,16g#,32f#,32f,32f #,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,g#"; //char *song = "A-Team:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#"; //char *song = "Flinstones:d=4,o=5,b=40:32p,16f6,16a#,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,d6,16f6,16a#.,16a#6,32g6,16f6,16a#.,3 2f6,32f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,a#,16a6,16d.6,16a#6,32a6,32a6,32g6,32f#6,32a6,8g6,16g6,16c.6,32a6,32a6,32g6,32g6,32f6,32e6,32g 6,8f6,16f6,16a#.,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#6,16c7,8a#. 6"; //char *song = "Jeopardy:d=4,o=6,b=125:c,f,c,f5,c,f,2c,c,f,c,f,a.,8g,8f,8e,8d,8c#,c,f,c,f5,c,f,2c,f.,8d,c,a#5,a5,g5,f5,p,d#,g#,d#,g#5,d#,g#,2d#,d#,g#,d#,g#,c.7,8a#,8g#,8g, 8f,8e,d#,g#,d#,g#5,d#,g#,2d#,g#.,8f,d#,c#,c,p,a#5,p,g#.5,d#,g# ;

Arduino Tone Library (11) RTTTL Player (5) 아두이노프로그램 //char *song = "Gadget:d=16,o=5,b=50:32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,32d#,32f,32f#,32g#,a#,d#6,4d6,32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,8d#"; //char *song = "Smurfs:d=32,o=5,b=200:4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8f#,p,8a#,p,4g#,4p,g#,p,a#,p,b,p,c6,p,4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8b,p,8f,p,4f#"; //char *song = "MahnaMahna:d=16,o=6,b=125:c#,c.,b5,8a#.5,8f.,4g#,a#,g.,4d#,8p,c#,c.,b5,8a#.5,8f.,g#.,8a#.,4g,8p,c#,c.,b5,8a#.5,8f.,4g#,f,g.,8d#.,f,g.,8d#.,f,8g,8d#.,f,8 g,d#,8c,a#5,8d#.,8d#.,4d#,8d#."; //char *song = "LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d #,8d,a#.5,e,32f,e,32f,c#,d#.,c#"; //char *song = "MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#, p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d"; void setup(void) { Serial.begin(9600); // tone1.begin(13); #define isdigit(n) (n >= '0' && n <= '9') void play_rtttl(char *p) { // Absolutely no error checking in here 24 byte default_dur = 4; byte default_oct = 6; int bpm = 63;

Arduino Tone Library (12) RTTTL Player (6) 아두이노프로그램 int num; long wholenote; long duration; byte note; byte scale; // format: d=n,o=n,b=nnn: // find the start (skip name, etc) while(*p!= ':') p++; // ignore name p++; // skip ':' // get default duration if(*p == 'd') { p++; p++; // skip "d=" num = 0; while(isdigit(*p)) { num = (num * 10) + (*p++ - '0'); if(num > 0) default_dur = num; p++; // skip comma Serial.print("ddur: "); Serial.println(default_dur, 10); 25

Arduino Tone Library (13) RTTTL Player (7) 아두이노프로그램 // get default octave if(*p == 'o') { p++; p++; // skip "o=" num = *p++ - '0'; if(num >= 3 && num <=7) default_oct = num; p++; // skip comma Serial.print("doct: "); Serial.println(default_oct, 10); // get BPM if(*p == 'b') { p++; p++; // skip "b=" num = 0; while(isdigit(*p)) { num = (num * 10) + (*p++ - '0'); bpm = num; p++; // skip colon Serial.print("bpm: "); Serial.println(bpm, 10); 26 // BPM usually expresses the number of quarter notes per minute wholenote = (60 * 1000L / bpm) * 4; // this is the time for whole note (in milliseconds) Serial.print("wn: "); Serial.println(wholenote, 10);

Arduino Tone Library (14) RTTTL Player (8) 아두이노프로그램 // now begin note loop while(*p) { // first, get note duration, if available num = 0; while(isdigit(*p)) { num = (num * 10) + (*p++ - '0'); if(num) duration = wholenote / num; else duration = wholenote / default_dur; // we will need to check if we are a dotted note after // now get the note note = 0; 27 switch(*p) { case 'c': note = 1; break; case 'd': note = 3; break; case 'e': note = 5; break; case 'f': note = 6; break; case 'g': note = 8; break; case 'a': note = 10; break;

Arduino Tone Library (15) RTTTL Player (9) 아두이노프로그램 case 'b': note = 12; break; case 'p': default: note = 0; p++; // now, get optional '#' sharp if(*p == '#') { note++; p++; // now, get optional '.' dotted note if(*p == '.') { duration += duration/2; p++; 28 // now, get scale if(isdigit(*p)) { scale = *p - '0'; p++;

Arduino Tone Library (16) RTTTL Player (10) 아두이노프로그램 else { scale = default_oct; scale += OCTAVE_OFFSET; if(*p == ',') p++; // skip comma for next note (or we may be at the end) 29 // now play the note if(note) { Serial.print("Playing: "); Serial.print(scale, 10); Serial.print(' '); Serial.print(note, 10); Serial.print(" ("); Serial.print(notes[(scale - 4) * 12 + note], 10); Serial.print(") "); Serial.println(duration, 10); tone(8, notes[(scale - 4) * 12 + note], duration); delay(duration); notone(8); else { Serial.print("Pausing: "); Serial.println(duration, 10); delay(duration);

Arduino Tone Library (17) RTTTL Player (11) 아두이노프로그램 void loop(void) { play_rtttl(song); Serial.println("Done."); while(1); 30

Piezzo Sensor (1) Piezzo Buzzer as Sensor Piezzo Buzzer 는 reverse-pizeoelectric 효과를보임 Piezo element 를움직임 (squeeze) 으로써전기를생성함. Piezzo Knock Sensor Piezzo element 에서생성된전기에의한전압을읽어 event 가발생하였음을검출할수있음 생성된전압을낮추기위해저항을연결할필요가있음 31

Piezzo Sensor (2) Piezzo Knock Sensor 회로구성 32

Piezzo Sensor (3) 아두이노프로그램 /* Knock Sensor This sketch reads a piezo element to detect a knocking sound. It reads an analog pin and compares the result to a set threshold. If the result is greater than the threshold, it writes "knock" to the serial port, and toggles the LED on pin 13. The circuit: * + connection of the piezo attached to analog in 0 * - connection of the piezo attached to ground * 1-megohm resistor attached from analog in 0 to ground http://www.arduino.cc/en/tutorial/knock */ // these constants won't change: const int ledpin = 13; // led connected to digital pin 13 const int knocksensor = A0; // the piezo is connected to analog pin 0 const int threshold = 100; // threshold value to decide when the detected sound is a knock or not // these variables will change: int sensorreading = 0; // variable to store the value read from the sensor pin int ledstate = LOW; // variable used to store the last LED status, to toggle the light 33 void setup() { pinmode(ledpin, OUTPUT); // declare the ledpin as as OUTPUT Serial.begin(9600); // use the serial port

Piezzo Sensor (4) 아두이노프로그램 void loop() { // read the sensor and store it in the variable sensorreading: sensorreading = analogread(knocksensor); // if the sensor reading is greater than the threshold: if (sensorreading >= threshold) { // toggle the status of the ledpin: ledstate =!ledstate; // update the LED pin itself: digitalwrite(ledpin, ledstate); // send the string "Knock!" back to the computer, followed by newline Serial.println("Knock!"); delay(100); // delay to avoid overloading the serial port buffer 34

Piezzo Sensor (5) 실험검토 Piezzo buzzer를두드리면벨처럼울리면서전압을출력일정한전압이상의시간을측정 이벤트발생여부확인다양한형태의센서제작가능 35

Flex Sensor (1) 개요 Angle Displacement Measurement Bends and Flexes physically with motion device Possible Uses Robotics, Gaming (Virtual Motion), Medical Devices, Computer Peripherals, Musical Instruments, Physical Therapy Simple Construction 36

Flex Sensor (2) 개요 동작방식 Electrical Characteristics Size: approx 0.28" wide and 1"/3"/5" long Resistance Range:1.5-40K ohms depending on sensor. Flexpoint claims a 0-250 resistance range. Lifetime: Greater than 1 million life cycles Temperature Range: -35 to +80 deg. Celcius Hysteresis: 7% Voltage: 5 to 12 V 37

Flex Sensor (3) 개요 동작방식 38

Flex Sensor 출력 (1) 실험개요 Flex sensor 값을읽어모니터에출력한다. 회로구성 39

Flex Sensor 출력 (2) 아두이노프로그램 // Flex sensor test program // HARDWARE: // Make the following connections between the Arduino and the flex sensor // Note that the flex sensor pins are interchangeable // Sensor pin - +5V // Sensor pin - Analog In 0, with 10K resistor to GND // INSTRUCTIONS: // Upload this sketch to your Arduino, then activate the Serial Monitor void setup() { // initialize serial communications Serial.begin(115200); void loop() { int sensor, degrees; // read the voltage from the voltage divider (sensor plus resistor) sensor = analogread(0); 40

Flex Sensor 출력 (3) 아두이노프로그램 // convert the voltage reading to inches // the first two numbers are the sensor values for straight (768) and bent (853) // the second two numbers are the degree readings we'll map that to (0 to 90 degrees) degrees = map(sensor, 768, 853, 0, 90); // note that the above numbers are ideal, your sensor's values will vary // to improve the accuracy, run the program, note your sensor's analog values // when it's straight and bent, and insert those values into the above function. // print out the result Serial.print("analog input: "); Serial.print(sensor,DEC); Serial.print(" degrees: "); Serial.println(degrees,DEC); // pause before taking the next reading delay(100); 41

과제물 #3 과제내용 1. Flex Sensor 입력을받아굽어진정도에따라 8 개의 LED 를비례하여출력하는출력하는프로그램을작성하여라. 2. 학기말과제와다음사항을제출하여라 A. 구현설계도 B. 부품목록및견적서 제출물 회로도, 프로그램소스, 실행예 ( 사진 ) 제출일 차주수업시간 42