Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<reg51.h>
- sbit gas = P3^3;
- sbit buzzer = P3^4;
- void delay(unsigned int);
- void main()
- {
- while(1)
- {
- if(gas==1)
- {
- buzzer=0;
- delay(100);
- }
- buzzer=1;
- }
- }
- void delay(unsigned int n)
- {
- unsigned char i;
- for(n;n>0;n--)
- {
- for(i=247;i>0;i--);
- for(i=247;i>0;i--);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement