This shows you the differences between two versions of the page.
|
pm:prj2023:apredescu:harp [2023/05/07 22:55] kambuorglu.batuhan created |
pm:prj2023:apredescu:harp [2023/05/28 21:55] (current) kambuorglu.batuhan [Hardware Design] |
||
|---|---|---|---|
| Line 18: | Line 18: | ||
| </note> | </note> | ||
| - | |||
| ===== Hardware Design ===== | ===== Hardware Design ===== | ||
| - | |||
| <note tip> | <note tip> | ||
| - | Here you put everything related to hardware design: | + | * 1 x Arduino Uno |
| - | * parts list | + | * 9 x 50Ω photo-resistors |
| - | * electrical schematics (can also be taken from the Internet and from datasheets, eg http://www.captain.at/electronic-atmega16-mmc-schematic.png) | + | * 9 x 5mW red laser diodes |
| - | * signal diagrams | + | * 9 x 4.7K Ω resistor |
| - | * simulation results | + | * 1 x Breadboard |
| + | * LCD | ||
| + | * speaker | ||
| + | * cables | ||
| </note> | </note> | ||
| + | |||
| + | ==== Schema Circuit ==== | ||
| + | {{ pm:prj2023:apredescu:harpbatuhan.jpg?400 |}} | ||
| + | |||
| + | {{ pm:prj2023:apredescu:lastbatuhan.jpg?400 |}} | ||
| ===== Software Design ===== | ===== Software Design ===== | ||
| <note tip> | <note tip> | ||
| - | Description of the application code (firmware): | + | <code> |
| - | * development environment (if any) (eg AVR Studio, CodeVisionAVR) | + | #include <LiquidCrystal.h> |
| - | * 3rd-party libraries and sources (eg Procyon AVRlib) | + | |
| - | * algorithms and structures you plan to implement | + | const int c = 262; |
| - | * (stage 3) sources and functions implemented | + | const int d = 294; |
| + | const int e = 330; | ||
| + | const int f = 349; | ||
| + | const int g = 392; | ||
| + | const int a = 440; | ||
| + | const int b = 494; | ||
| + | |||
| + | int kc = 0; | ||
| + | int kd = 0; | ||
| + | int ke = 0; | ||
| + | int kf = 0; | ||
| + | int kg = 0; | ||
| + | int ka = 0; | ||
| + | int kb = 0; | ||
| + | |||
| + | const int rs = 12; | ||
| + | const int en = 11; | ||
| + | const int d4 = 5; | ||
| + | const int d5 = 4; | ||
| + | const int d6 = 3; | ||
| + | const int d7 = 2; | ||
| + | const int contrastPin = A0; | ||
| + | |||
| + | const int lcdColumns = 20; | ||
| + | const int lcdRows = 4; | ||
| + | |||
| + | const int speakerPin = 9; // Broche de sortie audio | ||
| + | |||
| + | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); | ||
| + | |||
| + | const int photodiodePin_c = 0; | ||
| + | const int photodiodePin_d = 1; | ||
| + | const int photodiodePin_e = 6; | ||
| + | const int photodiodePin_f = 7; | ||
| + | const int photodiodePin_g = 8; | ||
| + | const int photodiodePin_a = 10; | ||
| + | const int photodiodePin_b = A2; | ||
| + | |||
| + | void setup() { | ||
| + | lcd.begin(lcdColumns, lcdRows); | ||
| + | analogWrite(contrastPin, 75); | ||
| + | lcd.print("Hello"); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | |||
| + | bool laserDetected_c = digitalRead(photodiodePin_c); | ||
| + | bool laserDetected_d = digitalRead(photodiodePin_d); | ||
| + | bool laserDetected_e = digitalRead(photodiodePin_e); | ||
| + | bool laserDetected_f = digitalRead(photodiodePin_f); | ||
| + | bool laserDetected_g = digitalRead(photodiodePin_g); | ||
| + | bool laserDetected_a = digitalRead(photodiodePin_a); | ||
| + | bool laserDetected_b = digitalRead(photodiodePin_b); | ||
| + | |||
| + | |||
| + | if (!laserDetected_c) { | ||
| + | Serial.println("c detected"); | ||
| + | tone(speakerPin, c); | ||
| + | kc = 1; | ||
| + | delay(300); | ||
| + | lcd.print("You are plaing a C !"); | ||
| + | } | ||
| + | if (!laserDetected_d) { | ||
| + | Serial.println("d detected"); | ||
| + | tone(speakerPin, d); | ||
| + | kd = 1; | ||
| + | delay(300); | ||
| + | lcd.print("You are plaing a D !"); | ||
| + | } | ||
| + | if (!laserDetected_e) { | ||
| + | Serial.println("e detected"); | ||
| + | tone(speakerPin, e); | ||
| + | ke = 1; | ||
| + | delay(300); | ||
| + | lcd.print("You are plaing a E !"); | ||
| + | } | ||
| + | if (!laserDetected_f) { | ||
| + | Serial.println("f detected"); | ||
| + | tone(speakerPin, f); | ||
| + | kf = 1; | ||
| + | delay(300); | ||
| + | lcd.print("You are plaing a F !"); | ||
| + | } | ||
| + | if (!laserDetected_g) { | ||
| + | Serial.println("g detected"); | ||
| + | tone(speakerPin, g); | ||
| + | kg = 1; | ||
| + | delay(300); | ||
| + | lcd.print("You are plaing a G !"); | ||
| + | } | ||
| + | if (!laserDetected_a) { | ||
| + | Serial.println("a detected"); | ||
| + | tone(speakerPin, a); | ||
| + | ka = 1; | ||
| + | delay(300); | ||
| + | lcd.print("You are plaing an A !"); | ||
| + | } | ||
| + | if (!laserDetected_b) { | ||
| + | Serial.println("b detected"); | ||
| + | tone(speakerPin, b); | ||
| + | kb = 1; | ||
| + | delay(300); | ||
| + | lcd.print("You are plaing a B !"); | ||
| + | } | ||
| + | |||
| + | if (laserDetected_c && kc==1) { | ||
| + | noTone(speakerPin); | ||
| + | kc = 0; | ||
| + | delay(300); | ||
| + | } | ||
| + | if (laserDetected_d && kd==1) { | ||
| + | noTone(speakerPin); | ||
| + | kd = 0; | ||
| + | delay(300); | ||
| + | } | ||
| + | if (laserDetected_e && ke==1) { | ||
| + | noTone(speakerPin); | ||
| + | ke = 0; | ||
| + | delay(300); | ||
| + | } | ||
| + | if (laserDetected_f && kf==1) { | ||
| + | noTone(speakerPin); | ||
| + | kf = 0; | ||
| + | delay(300); | ||
| + | } | ||
| + | if (laserDetected_g && kg==1) { | ||
| + | noTone(speakerPin); | ||
| + | kg = 0; | ||
| + | delay(300); | ||
| + | } | ||
| + | if (laserDetected_a && ka==1) { | ||
| + | noTone(speakerPin); | ||
| + | ka = 0; | ||
| + | delay(300); | ||
| + | } | ||
| + | if (laserDetected_b && kb==1) { | ||
| + | noTone(speakerPin); | ||
| + | kb = 0; | ||
| + | delay(300); | ||
| + | } | ||
| + | |||
| + | |||
| + | delay(100); | ||
| + | |||
| + | |||
| + | } | ||
| + | </code> | ||
| </note> | </note> | ||