Uploaded by mohammadali hoshivar

HW 5

advertisement
1. Why does an LED emit light, but a rectifier diode can't emit light?
Standard diodes are made of silicon, an indirect band gap material, thus no photon emission is
possible. LEDs are made of direct band gap semiconductors like GaAs. It also can be regarding to
the bad gap which is too small. The band gap is the energy differences between the level of
valances and conductions. When a free electron recombines with a hole, it gives off a photon that
has the energy (more or less) of the difference.
2. Calculate the current and power requirements for all components in your individual
project? Show all details
Element
Current(A)
Voltage(V)
Power(W)
Photoresistor
6.67E-04
150
0.1
Ultrasonic sensors
0.05
5
0.25
DHT11
0.003
5.5
0.0165
RED LED
0.002
2.1
0.0042
Green LED
0.002
3.2
0.0064
LCD 1602
0.0011
5
0.055
Potentiometers
7.5E-4
200
0.15
Table 1. Elements Power, Current, Voltage Value
https://www.make-it.ca/10mm-led-specifications/
https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/SEN-09088.pdf
https://components101.com/sites/default/files/component_datasheet/DHT11-TemperatureSensor.pdf
https://repository.unair.ac.id/55279/4/FV.OSI.42-16%20Bah%20%20r-3.pdf
https://www.openhacks.com/uploadsproductos/eone-1602a1.pdf
https://www.arduino.cc/documents/datasheets/ACP_potentiometers.pdf
3. Buzzers can be found in alarm devices, computers, timers, and confirmation of user input such as a
mouse click or keystroke. Use Arduino and buzzer to generate a sound signal with a certain frequency
(you choose) only when the potentiometer reading voltage is above 3.8 volt. Hints: you may need to
use tone (), no Tone() functions Show circuit, code, and video showing your circuit is working based
on the above conditions
Code
#include "pitches.h"
// constants won't change
const int POTEN = A1; // Arduino pin connected to Potentiometer pin
const int BUZpin = 13; // Arduino pin connected to Buzzer's pin
const float VOLTAGE_THRESHOLD = 3.75; // Voltages
// notes in the melody:
int melody[] = {
NOTE_FS5, NOTE_FS5, NOTE_D5, NOTE_B4, NOTE_B4, NOTE_E5,
NOTE_E5, NOTE_E5, NOTE_GS5, NOTE_GS5, NOTE_A5, NOTE_B5,
NOTE_A5, NOTE_A5, NOTE_A5, NOTE_E5, NOTE_D5, NOTE_FS5,
NOTE_FS5, NOTE_FS5, NOTE_E5, NOTE_E5, NOTE_FS5, NOTE_E5
};
// note durations: 4 = quarter note, 8 = eighth note, etc, also called tempo:
int noteDurations[] = {
8, 8, 8, 4, 4, 4,
4, 5, 8, 8, 8, 8,
8, 8, 8, 4, 4, 4,
4, 5, 8, 8, 8, 8
};
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A1);
int analogValue = analogRead(POTEN); // read the input on analog pin
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
delay(5);
if(voltage > VOLTAGE_THRESHOLD)
buzzer(); // play a song
}
float floatMap(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void buzzer() {
// iterate over the notes of the melody:
int size = sizeof(noteDurations) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) {
// 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(BUZpin, melody[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.5;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(BUZpin);
}
}
Figure 1. Circuit diagram
Figure 2. Circuit schematic
References:
Why does only the LED emits light not . (n.d.). Retrieved March 1, 2022, from
https://www.quora.com/Why-does-only-the-LED-emits-light-not-the-other-diodes
Download