51 MCU water tower schematic diagram and source program

Publisher:郑哥Latest update time:2020-08-21 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The source program of the single chip microcomputer is as follows:
#include
//Define an array so that the numbers displayed by the digital tube are equal to the subscripts of the array elements
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,
                            0x6d,0x7d,0x07,0x7f,0x6f};
sbit shuiman=P1^0;//water full
sbit sw5=P1^1;//water level 5
sbit sw4=P1^2;//water level 4 sbit sw3=P1^
3;//water level 3
sbit sw2=P1^4;//water level 2
sbit sw1=P1^5;//water level 1
sbit shougong=P1^6;//manual water filling
sbit dianji=P1^7;//motor control
bit sbit state=P3^7;//Motor working indication
/*Delay program*/
void delay02s(void)
{
  unsigned char i,j,k;
  for(i=100;i>0;i--)
  for(j=100;j>0;j--)
  for(k=248;k>0;k--);
}
main()
{
  P0=0;
  while(1)
    { /*************************The sensor is designed to trigger only one sensor unit at a time?****************************
        //Water fullif
      (shuiman==0&&sw5==1&&sw4==1&&sw3==1&&sw2==1&&sw1==1)//Occurs when only one sensor unit is closed: water level 6
      {
        dianji=1;//Turn off the motorstate
        =1;//The motor working indicator light goes outP0
            =table[6];//Show water level depth: 6**** Full
        delay02s(); // Delay for a while to let the digital tube display a prompt: the water is full
      }
        // Water level 5
      if(shuiman==1&&sw5==0&&sw4==1&&sw3==1&&sw2==1&&sw1==1)// Occurs when only one sensor unit is closed: water level 5
      {
        P0=table[5]; // Display water level depth: 5
      }
      // Water level 4
      if(shuiman==1&&sw5==1&&sw4==0&&sw3==1&&sw2==1&&sw1==1)// Occurs when only one sensor unit is closed: water level 4
      {
        P0=table[4]; // Display water level depth: 4
      }
      // Water level 3
      if(shuiman==1&&sw5==1&&sw4==1&&sw3==0&&sw2==1&&sw1==1)//When only one sensor unit is closed: water level 3
      {
          P0=table[3]; //Display water level depth: 5
      }
      //Water level 2
        if(shuiman==1&&sw5==1&&sw4==1&&sw3==1&&sw2==0&&sw1==1)//When only one sensor unit is closed: water level 2
      {
        P0=table[2]; //Display water level depth: 2
      }
      //Water level low
      if(shuiman==1&&sw5==1&&sw4==1&&sw3==1&&sw2==1&&sw1==0)//When only one sensor unit is closed: water level 1
      {
        dianji=0;//turn on the motor
        state=0;//the motor working indicator light turns on
      P0=table[1];//displays the water level depth: 1
      }
      //manual water
        fillingif(shougong==0)//occurs when the manual water filling button is pressed
      {  
          dianji=0;//turn on the motor
        state=0;//the motor working indicator light turns on
        P0=table[0];//displays 0, indicating that manual water filling has responded
        delay02s();//delay for a period of time to let the digital tube display a prompt: manual water filling has started
      }
   
    }
   
}

Reference address:51 MCU water tower schematic diagram and source program

Previous article:Single chip infrared transmitting and receiving circuit
Next article:LCD1602+DTH11+MQ-135 air pollution detection temperature and humidity program

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号