FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    How to use 51 single-chip microcomputer to achieve addition and subtraction

     

    "Development tools: Keil Simulation tool: proteus The code is as follows: Header file: Inc_ all.h 1 #ifndef INC_ ALL_ H_ 2 #define INC_ ALL_ H_ three 4 volatile unsigned char keyValue; 5 volaTIle unsigned char sign; 6 volaTIle long int opr1; 7 volaTIle long int opr2; 8 volaTIle long int SysValue=0; 9 volatile int keyCounter; 10 volatile int cnt50ms=0; 11 volatile bit StartFlag; twelve 13 void Init_ Timer0(); 14 void Init_ Timer1(); 15 void delayms(int t); 16 unsigned char KeyScan(void); 17 void showNumber(long int num); 18 void keyAnalyzing(unsigned char keyval); nineteen 20 #endif The source file is as follows: main. C 1 #include 2 #include “inc_ all.h” 3 //======================================================= 4 / / nixie tube display decoding, common cathode 5 / / 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, off, 'e', '-' 6 //======================================================= 7 unsigned char code table[]={0x3F,0x06,0x5b,0x4F,0x66, 8 0x6d,0x7d,0x07,0x7F,0x6F, 9 0x00/* trun off */, 10 0x79/* Error */, 11 0x40/* - */}; 12 //======================================================== 13 / / timer 0 initializes the function, timing 50ms 14 / / start counting with the "start" key on the keyboard 15 / / pause counting with the "sus" key on the keyboard 16 //======================================================== 17 void Init_ Timer0() 18 { 19 TMOD |= 0x01; 20 TH0 = 0x3C; 21 TL0 = 0xB0; 22 TR0 = 0; 23 ET0 = 1; 24 } 25 //========================================================= 26 / / timer 1 initialization function 27 / / timing: 23 MS, for display 28 / / timing starts after initialization 29 //========================================================= 30 void Init_ Timer1() 31 { 32 TMOD |= 0x10; 33 TH1 = 0xA6; 34 TL1 = 0x28; 35 TR1 = 1; 36 ET1 = 1; 37 } 38 //========================================================= 39 / / delay function 40 //========================================================= 41 void delayms(int t) 42 { 43 int i,j; 44 for(i=t; i》0; i--) 45 for(j=25; j》0; j--) 46 ; 47 } 48 //========================================================= 49 / / four digit nixie tube display function 50 / / it can automatically turn off zero and automatically identify the sign 51 / / when the value exceeds the display range, an error "e ---" is displayed 52 //========================================================= 53 void showNumber(long int num) 54 { 55 unsigned char q,s,b,g; 56 if(num》=0) 57 { 58 q = num/1000; 59 b = num/100%10; 60 s = num/10%10; 61 g = num%10; 62 if(num《10) 63 { 64 q = 10; 65 b = 10; 66 s = 10; 67 } 68 else if(num《100) 69 { 70 q = 10; 71 b = 10; 72 } 73 else if(num《1000) 74 q = 10; 75 else if(num》9999) 76 { 77 q = 11; // show error 78 b = 12; 79 s = 12; 80 g = 12; 81 } 82 } 83 else 84 { 85 if(num》-1000) 86 { 87 q = 12; 88 b = (0-num)/100; 89 s = (0-num)/10%10; 90 g = (0-num)%10; 91 } 92 else 93 { 94 q = 11; // show error 95 b = 12; 96 s = 12; 97 g = 12; 98 } 99 } 100 P0 = 0x00; 101 P0 = table[q]; 102 P2 = 0xFE; 103 delayms(10); 104 P0 = 0x00; 105 P0 = table[b]; 106 P2 = 0xFD; 107 delayms(10); 108 P0 = 0x00; 109 P0 = table[s]; 110 P2 = 0xFB; 111 delayms(10); 112 P0 = 0x00; 113 P0 = table[g]; 114 P2 = 0xF7; 115 delayms(10); 116 } 117 //========================================================= 118 / / keyboard scanning function 119 / / press the key to return the scanning result 120 //========================================================= 121 unsigned char KeyScan(void) 122 { 123 unsigned char temp=0xF0; 124 P1 = temp; 125 temp = P1; 126 if(temp!= 0xF0) 127 { 128 delayms(5); // debounce 129 temp = P1; 130 if(temp!= 0xF0) 131 { 132 int t=0x01,i; 133 for(i=0; i《4; i++) 134 { 135 P1 = ~(t《 136 temp = P1; 137 switch (Temp) / / scan by line 138 { 139 case 0xee: return ‘1’; 140 case 0xde: return ‘2’; 141 case 0xbe: return ‘3’; 142 case 0x7e: return ‘+’; // plus one hundred and forty-three 144 case 0xed: return ‘4’; 145 case 0xdd: return ‘5’; 146 case 0xbd: return ‘6’; 147 case 0x7d: return ‘-’; // minus sign one hundred and forty-eight 149 case 0xeb: return ‘7’; 150 case 0xdb: return ‘8’; 151 case 0xbb: return ‘9’; 152 case 0x7b: return ‘r’; // reset one hundred and fifty-three 154 case 0xe7: return ‘0’; 155 case 0xd7: return ‘s’; // start-up 156 case 0xb7: return ‘t’; // suspend 157 case 0x77: return ‘=’; // be equal to 158 default: ; 159 } 160 } 161 } 162 } 163 return ‘0’; 164 } 165 / / ==================================================================== Design of NVIC interrupt control of 51 single chip microcomputer How to use 51 single chip microcomputer to realize addition and subtraction calculation Usage analysis of USB communication of stm32f107 series single chip microcomputer Design of PWM input capture mode of STM32 single chip microcomputer MCU SPI communication protocol application, Download enthusiast app Create an electronic circle of your contacts Pay attention to wechat of electronic enthusiasts Interesting and informative information and technology dry goods Focus on enthusiast class Lock in the latest course activities and technology live broadcast Electronic enthusiast observation Front line report, in-depth observation, latest information, collected 1 person collection Share:, comment Lin Chaowen PCB Design: pads tutorial, pads video tutorial, Zheng Zhenyu teacher: Altium designer tutorial, Altium designer video tutorial, Zhang Fei actual combat electronic video tutorial, Zhu Youpeng teacher: Hisilicon hi3518e tutorial, hi3518e video tutorial, Li Zeng teacher: signal integrity tutorial, high-speed circuit simulation tutorial, Huawei Hongmeng system tutorial, harmonyos video tutorial, saisheng: EMC design tutorial, EMC video tutorial Mr. Du Yang: STM32 tutorial, STM32 video tutorial, Tang zuolin: C language basic tutorial, C language basic video tutorial, Zhang Fei: Buck Power tutorial, buck power video tutorial, punctual atom: FPGA tutorial, FPGA video tutorial, Mr. Wei Dongshan: embedded tutorial, embedded

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us