Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IoT 1팀] 중간점검 PR #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions iot1/Step2 Notion 링크.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://www.notion.so/Step-2-Mission-1-effba72bbac04240aa65ae6b622f2097
Binary file added iot1/Step2 Notion.pdf
Binary file not shown.
35 changes: 35 additions & 0 deletions iot1/class2/Melody/Melody.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef Melody_CPP
#define Melody_CPP

#include "Arduino.h"
#include "Melody.h"

float songs[][200]={
{//HarryPotter OST - Hedwig's Theme
b4, 4, e5, 2.7, g5, 8, fs5, 4, e5, 2, b5, 4, a5, 1.3, fs5, 1.3,
e5, 2.7, g5, 8, fs5, 4, ds5, 2, fs5, 4, b4, 1.3,
e5, 2.7, g5, 8, fs5, 4, e5, 2, b5, 4, d6, 2, cs6, 4, c6, 2, gs5, 4,
c6, 2, b5, 4, as5, 4, as4, 2, g5, 4, e5, 1.3, g5, 4,
b5, 2, g5, 4, b5, 2, g5, 4, c6, 2, b5, 4, as5, 2, fs5, 4,
g5, 2.7, b5, 8, as5, 4, as4, 2, b4, 4, b5, 1.3, g5, 4,
b5, 2, g5, 4, b5, 2, g5, 4, d6, 2, cs6, 4, c6, 2, gs5, 4,
c6, 2.7, b5, 8, as5, 4, as4, 2, g5, 4, e5, 1.3
},
{//도레미파솔라시도
c4, 4, d4, 4, e4, 4, f4, 4, g4, 4, a4, 4, b4, 4, c5, 4
}};

void play(int Pin, int num){
int notes = sizeof(songs[0])/sizeof(songs[0][0]);

for (int i = 1; i < notes;){
int durations = 1000 / songs[num][i];

tone(Pin, songs[num][i-1], durations);
delay(durations*1.5);
i = i+2;
}
noTone(Pin);
}

#endif
103 changes: 103 additions & 0 deletions iot1/class2/Melody/Melody.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#ifndef Melody_H
#define Melody_H

#define c1 33
#define cs1 35
#define d1 37
#define ds1 39
#define e1 41
#define f1 44
#define fs1 46
#define g1 49
#define gs1 52
#define a1 55
#define as1 58
#define b1 62
#define c2 65
#define cs2 69
#define d2 73
#define ds2 78
#define e2 82
#define f2 87
#define fs2 93
#define g2 98
#define gs2 104
#define a2 110
#define as2 117
#define b2 123
#define c3 131
#define cs3 139
#define d3 147
#define ds3 156
#define e3 165
#define f3 175
#define fs3 185
#define g3 196
#define gs3 208
#define a3 220
#define as3 233
#define b3 247
#define c4 262
#define cs4 277
#define d4 294
#define ds4 311
#define e4 330
#define f4 349
#define fs4 370
#define g4 392
#define gs4 415
#define a4 440
#define as4 466
#define b4 494
#define c5 523
#define cs5 554
#define d5 587
#define ds5 622
#define e5 659
#define f5 698
#define fs5 740
#define g5 784
#define gs5 831
#define a5 880
#define as5 932
#define b5 988
#define c6 1047
#define cs6 1109
#define d6 1175
#define ds6 1245
#define e6 1319
#define f6 1397
#define fs6 1480
#define g6 1568
#define gs6 1661
#define a6 1760
#define as6 1865
#define b6 1976
#define c7 2093
#define cs7 2217
#define d7 2349
#define ds7 2489
#define e7 2637
#define f7 2794
#define fs7 2960
#define g7 3136
#define gs7 3322
#define a7 3520
#define as7 3729
#define b7 3951
#define c8 4186
#define cs8 4435
#define d8 4699
#define ds8 4978
#define e8 5274
#define f8 5588
#define fs8 5920
#define g8 6272
#define gs8 6645
#define a8 7040
#define as8 7459
#define b8 7902

void play(int, int);

#endif
17 changes: 17 additions & 0 deletions iot1/class2/Piezo_Buzzer/Piezo_Buzzer.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <Melody.h>

int BuzzerPin = 2;

void setup()
{
pinMode(BuzzerPin, OUTPUT);
}

void loop()
{
//도레미파솔라시도 출력
play(BuzzerPin, 1);

//HarryPotter OST - Hedwig'd Theme 출력
play(BuzzerPin, 0);
}
37 changes: 37 additions & 0 deletions iot1/class2/Ultrasonic_Piezo/Ultrasonic_Piezo.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
int TrigPin = 7;
int EchoPin = 6;
int BuzzerPin = 2;

void setup()
{
pinMode(TrigPin, OUTPUT);
pinMode(EchoPin, INPUT);
pinMode(BuzzerPin, OUTPUT);
}

void loop()
{
//초음파 송신
digitalWrite(TrigPin, HIGH);
delayMicroseconds(10);
digitalWrite(TrigPin, LOW);

//초음파 수신
float duration = pulseIn(EchoPin, HIGH);

//거리를 cm로 변환
float distance = 340*duration / 10000 / 2;

//거리에 따른 경고음 출력
if(distance >= 100 && distance < 200){
tone(BuzzerPin, 392, 300);
delay(1200);
}else if(distance >= 50 && distance < 100){
tone(BuzzerPin, 392, 300);
delay(800);
}else if(distance < 50){
tone(BuzzerPin, 392, 300);
delay(500);
}else
noTone(BuzzerPin);
}
26 changes: 26 additions & 0 deletions iot1/class2/Ultrasonic_Sensor/Ultrasonic_Sensor.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
int TrigPin = 7;
int EchoPin = 6;

void setup()
{
Serial.begin(9600);
pinMode(TrigPin, OUTPUT);
pinMode(EchoPin, INPUT);
}

void loop()
{
//초음파 송신
digitalWrite(TrigPin, HIGH);
delayMicroseconds(10);
digitalWrite(TrigPin, LOW);

//초음파 수신
float duration = pulseIn(EchoPin, HIGH);

//물체와의 거리를 cm로 변환
float distance = 340*duration / 10000 / 2;

Serial.print("distance : ");
Serial.println(distance);
}
11 changes: 11 additions & 0 deletions iot1/class3/1_Blink/1_Blink.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
12 changes: 12 additions & 0 deletions iot1/class3/2_ExternalLED/2_ExternalLED.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
int LED_pin = 8;
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_pin, OUTPUT);
}

void loop() {
digitalWrite(LED_pin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_pin, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Binary file added iot1/class3/2_ExternalLED/ExternalLED.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions iot1/class3/3_LEDBrightness/3_LEDBrightness.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const int LED = 11;

void setup() {
}

void loop() {
for(int t_high=0; t_high<=255; t_high++) {
analogWrite(LED, t_high);
delay(4);
}
}
Binary file added iot1/class3/3_LEDBrightness/Brightness.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading