Lesson 7

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

BleeperBuzzer

25
5000
Relay


Buzzer
Buzzer

level mode Buzzer


Beeper
Buzzer level Buzzer
frequency mode


Buzzer Buzzer

Buzzer
datasheet





Buzzer




Buzzer


Buzzer
A0
Porta.f0=1;


Buzzer
A0
Porta.f0=0;
Buzzer


B7B0
A0 BuzzerA1
void main()

trisa.f0=1; trisa.f1=0; trisb=0;

portb=0;

while(1) {
if(porta.f1==0) {
porta.f0=1;

Buzzer

// Buzzer ON

portb++;
while(porta.f1==0){ }
porta.f0=0;
}
}
}

// wait

// Buzzer OFF





Buzzer

BleeperBuzzer


Buzzer
Buzzer
Buzzer


transistor as a switch








RB
Base
collector
Buzzer emitter
Buzzeropen circuit



Buzzer
Buzzer
porta.f0=1;
porta.f0=0;Buzzer

Base


porta.f0=1;

porta.f0=0;


Buzzer

MOSFET










A0
Buzzer porta.f0=1;
open circuitporta.f0=0;
Buzzer

MOSFETBJT

Buzzer speaker
piezo transducerfrequency mode Buzzer

speakerloudspeaker
speaker




portb.f0=0; delay_ms(5) ; portb.f0=1;
while(1) {

} delay_ms(5);


speaker
piezo transducer
Buzzer


portb.f0=1; delay_ms(5) ;
Hi
portb.f0=0; delay_ms(5);
low








10



B0

void main()
{ trisb=0;

portb=0;

while(1) {
portb.f0=1; delay_ms(3);

portb.f0=0; delay_ms(3);

B0


B0
while(1) {
portb.f0=1; delay_ms(4);
portb.f0=0; delay_ms(1);
}

B0


B0

10 x 10 0.01

while(1) {
portb.f0=1; delay_ms(5);

portb.f0=0; delay_ms(5);






while(1) {
portb.f0=1; delay_ms(8);
portb.f0=0; delay_ms(2);


while(1) {
portb.f0=1; delay_ms(6);
portb.f0=0; delay_ms(4);
}


delay_ms

x

um
delay_us(1);



10000


= x


while(1) {

portb.f0=1; delay_us(50);
portb.f0=0; delay_us(50);


B0
while(1) {


portb.f0=1; delay_us(5);

portb.f0=0; delay_us(5);


100 KHz


Buzzer

coupling capacitor

headphone





void main()

{ trisb=0; portb=0;
while(1) {

portb.f0=1; delay_ms(1);

portb.f0=0; delay_ms(1);






void main()

{ trisb=0; portb=0;

while(1) {

}
}

portb.f0=1; delay_ms(2);

portb.f0=0; delay_ms(1);



proteus
delay_us
void main()

{ trisb=0; portb=0;

while(1) {
portb.f0=1; delay_us(100);

portb.f0=0; delay_ms(100);



while(1) { }
for
void main()

{ int x;

trisb=0; portb=0;

for(x=0;x<2000;x++){
portb.f0=1; delay_us(100);
portb.f0=0; delay_ms(100);
}
}



for
intchar

for
x




delay_us( )

delay




for


void main()

{ int x;

trisb=0; portb=0;
while(1){
for(x=0;x<300;x++){ portb.f0=1; delay_us(700);
portb.f0=0; delay_us(700);}
for(x=0;x<300;x++){ portb.f0=1; delay_us(750);
portb.f0=0; delay_us(750);}
for(x=0;x<250;x++){ portb.f0=1; delay_us(800);
portb.f0=0; delay_us(800);}
for(x=0;x<220;x++){ portb.f0=1; delay_us(750);
portb.f0=0; delay_us(750);}
for(x=0;x<400;x++){ portb.f0=1; delay_us(700);
portb.f0=0; delay_us(700);}
for(x=0;x<420;x++){ portb.f0=1; delay_us(600);
portb.f0=0; delay_us(600);}
for(x=0;x<350;x++){ portb.f0=1; delay_us(650);
portb.f0=0; delay_us(650);}
for(x=0;x<320;x++){ portb.f0=1; delay_us(650);
portb.f0=0; delay_us(650);}
for(x=0;x<300;x++){ portb.f0=1; delay_us(700);
portb.f0=0; delay_us(700);}
}
}


for


x delay_ms(x);
while(1)
x++;
void main( )
{ int x;

trisb=0;

portb=0;

while(1){ portb.f0=1; delay_us(x);

portb.f0=0; delay_us(x);

x++;
}
}


x
delay_us(2) delay_us(1)





delay_us(1);
for x

for(y=0;y<x;y++) delay_us(1);

x
for
for(y=0;y<15;y++) {


{ }


xx
x x
x

for(y=0;y<x;y++) delay_us(1);

void main( )
{ int x;

trisb=0;

portb=0;

while(1){ portb.f0=1; delay_us(x);


portb.f0=0; delay_us(x);

x++;


void main( )
{ int x,y;

trisb=0;

portb=0;

while(1){ portb.f0=1; for(y=0;y<x;y++) delay_us(1);


portb.f0=0; for(y=0;y<x;y++) delay_us(1);
x++;
}
}



for
x++; x

delay_us( )

delay_us(1)

Oscillators

cycles



RC Oscillator

Proteus
pic16f84a

for if
Assembly languge


CRRC Oscillator


Crystal oscillator




RC oscillator


_RC_OSC
_XT_OSC
_HS_OSC


RC oscillator _RC_OSC
200_XT_OSC
4
254_HS_OSC

20
20 000 000

_HS_OSC


Default
HSXTRC


RC OSC
CR

3.3 MHz
22 pF
3.3 K
2.3 MHz
22 pF
4.7 K
1.08 MHz
22 pF
10 K
2.4 MHz
30 pF
3.3 K
1.7 MHz
30 pF
4.7 K
0.793 MHz
30 pF
10 K
1.08MHz
RC
OSC1

RC OSCILLATOR


OSC2OSC1


DatasheetOSC1,OSC2
pin diagram
OSC1,OSC2


pic16f84a
OSC1
OSC2

HSXTCRYSTAL MODE

MODE

XT
100 KHz
100-150 pF
XT
200 KHz
22-68 pF
XT
2 MHz
15-33 pF
XT
4 MHz
15-33 pF
HS
4 MHz
15-33 pF
HS
8 MHz
15-33 pF
HS
10 MHz
15-33 pF
HS
20 MHz
15-33 pF

15-33Pf
15-33pF

pic16f84 datasheet











ceramic resonator

OSC1,OSC2


resonator
_XT_OSC HS XT mode

_HS_OSC resonator
4resonato


OSC2OSC1
Resonators








4MHz crystal
_HS_OSC_XT_OSC
void main(){ int x; trisb=0; portb=0;

while(1){
for(x=0;x<400;x++){ portb.f0=1;
portb.f0=0;
for(x=0;x<450;x++){ portb.f0=1;
portb.f0=0;
}

delay_us(750);

delay_us(800);}

delay_us(500);

delay_us(750);}




void main(){ int x; trisb=0; portb=0;

while(1){
for(x=0;x<400;x++){ portb.f0=1;
portb.f0=0;
for(x=0;x<450;x++){ portb.f0=1;
portb.f0=0;
}

delay_us(450);

delay_us(480);}

delay_us(350);

delay_us(450);}


for(y=0;y<x;y++) delay_us(1);

void main()
{ int x,y;

trisb=0;

portb=0;

while(1){

for(x=1;x<300;x++){
portb.f0=1;

for(y=0;y<x;y++)delay_us(10);

portb.f0=0; for(y=0;y<x;y++)delay_us(10);
}
}
}

while(1)for
for
portb.f0=1; x=1
x for(y=0;y<x;y++)delay_us(10);
for
portb.f0=0;
forx
portb.f0=1;
for(y=0;y<x;y++)delay_us(10);
for x
portb.f0=0;
for x



void main()
{ int x,y;


trisb=0;

portb=0;

while(1){

for(x=250;x>0;x--){
portb.f0=1;

for(y=0;y<x;y++)delay_us(5);

portb.f0=0;

for(y=0;y<x;y++)delay_us(5);

portb.f0=1;

for(y=0;y<x;y++)delay_us(10);
}

void main()
{ int x,y;

trisb=0;

portb=0;

while(1){

for(x=0;x<50;x++){
portb.f0=1;

for(y=0;y<x;y++)delay_us(10);

portb.f0=0; for(y=0;y<x;y++)delay_us(10);
}
}
}

for
for

You might also like