Skip to main content

Interfacing of LEDs and testing Buzzer using Arduino and Proteus

Task 1:
Make a sketch for interfacing of Buzzer with Arduino at pin 9.
Solution: Code
const int buzzer=9;
void setup() {
  pinMode(buzzer,OUTPUT);
}
void loop() {
 tone(buzzer,3000); //Send 3KHz sound signal....
 delay(5000);      //....for 5 sec
 noTone(buzzer);  // Stop sound...
 delay(1500);    //...for 1.5s
}
Task 2:
Flashing of 5 LED with different pattern.
Solution: Code

int led1=1;
int led2=2;
int led3=3;
int led4=4;
int led5=5;
void setup() {
 pinMode(led1,OUTPUT);
  pinMode(led2,OUTPUT);
  pinMode(led3,OUTPUT);
  pinMode(led4,OUTPUT);
  pinMode(led5,OUTPUT);
}
void loop() {
 // first cycle
 digitalWrite(led1,HIGH);
 delay(500);
 digitalWrite(led2,LOW);
 delay(500);
 digitalWrite(led3,HIGH);
 delay(500);
 digitalWrite(led4,LOW);
 delay(500);
 digitalWrite(led5,HIGH);
 delay(500);
// Second cycle
 digitalWrite(led1,LOW);
 delay(500);
 digitalWrite(led2,HIGH);
 delay(500);
 digitalWrite(led3,LOW);
 delay(500);
 digitalWrite(led4,HIGH);
 delay(500);
 digitalWrite(led5,LOW);
 delay(500);
}

Comments

Popular posts from this blog

Major courses of Electrical Engineering

Electrical Engineering is the major branch of engineering and is the professional engineering.Due to this reason,millions of students take admission  in universities all over the world after 12 class (Fsc Pre-Engineering).Before admission every students wants to how know about their subject(courses). Following are the major and common subject that are read in every universities. Electrical Workshop Linear Circuit Analysis Electrical Network Analysis Digital Logic Design Engineering Drawing Electronic Devices and circuit Electrical Machine and Motors Digital Signal Processing Electromagnetic Field theory   Microprocessor System These courses almost read in every institute of Engineering.