Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2023:apredescu:harp [2023/05/25 18:13]
kambuorglu.batuhan [Hardware Design]
pm:prj2023:apredescu:harp [2023/05/28 21:55] (current)
kambuorglu.batuhan [Hardware Design]
Line 20: Line 20:
 ===== Hardware Design ===== ===== Hardware Design =====
 <note tip> <note tip>
-1 x Arduino Uno +  * 1 x Arduino Uno 
-9 x 50Ω photo-resistors +  ​* ​9 x 50Ω photo-resistors 
-9 x 5mW red laser diodes +  ​* ​9 x 5mW red laser diodes 
-9 x 4.7K Ω resistor +  ​* ​9 x 4.7K Ω resistor 
-1 x Breadboard  +  ​* ​1 x Breadboard  
-cables+  * LCD 
 +  * speaker  
 +  * cables
 </​note>​ </​note>​
-=== Schema ​Electrica ​=== + 
-{{:pm:​prj2023:​apredescu:​harpbatuhan.jpg|}}+ 
 +==== 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 StudioCodeVisionAVR+#include <​LiquidCrystal.h>​ 
-  ​* 3rd-party libraries and sources ​(eg Procyon AVRlib+ 
-  ​* algorithms and structures you plan to implement +const int c = 262; 
-  ​(stage 3sources 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(speakerPinc)
 +    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>​
  
pm/prj2023/apredescu/harp.1685027630.txt.gz · Last modified: 2023/05/25 18:13 by kambuorglu.batuhan
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0