• C51学习 之 A/D D/A


    A/D电路图(ADC0804)

    代码

     1 #include <reg52.h>
     2 
     3 sbit wela = P2^7;
     4 sbit dula = P2^6;
     5 sbit dawr = P3^6;
     6 sbit dacs = P3^2;
     7 sbit beep = P2^3;
     8 
     9 void delay(unsignd int time)
    10 {
    11     while(time--);
    12 }
    13 
    14 void init()
    15 {
    16     dula = 0;
    17     wela = 0;
    18     dacs = 0;
    19     dawr = 0;
    20     P0 = 0;
    21 }
    22 
    23 int main()
    24 {
    25     unsigned char var,flag;
    26     init();
    27     while (1) {
    28         if (flag == 0) {
    29             val += 5;
    30             P0 = val;
    31         }
    32         if (val == 255) {
    33             flag = 1;
    34             beep = 0;
    35             delay(10000);
    36             beep = 1;
    37         }
    38         delay(5000);
    39     } else {
    40         val -= 5;
    41         P0 = val;
    42         if (val == 0) {
    43             flag = 0;
    44             beep = 0;
    45             delay(10000);
    46             beep = 1;
    47             
    48         }
    49         delay(5000);
    50     }
    51 }
  • 相关阅读:
    正则表达式之re模块
    collections模块
    openpyxl模块
    hashlib模块
    random模块
    os模块
    sys模块
    nodeType
    数据类型转换
    添加删除
  • 原文地址:https://www.cnblogs.com/wangfeicom/p/14839175.html
Copyright © 2020-2023  润新知