AVR (ATMEGA128/ATMEGA16) digital tube display

Publisher:平和思绪Latest update time:2016-10-19 Source: eefocusKeywords:AVR  ATMEGA128  ATMEGA16 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
This is a multi-file format, the program is 128, 16 is no different

PROTEUS simulation diagram

AVR (ATMEGA128/ATMEGA16) digital tube display program - Proofreading - bbmingxiao's blog

/****************led digital tube header file************************/
#ifndef __led_H__
#define __led_H__

#define led_wei_ddr  DDRD|=0X0F
#define led_wei PORTD
#define led_duan_ddr DDRF=0XFF
#define led_duan PORTF

extern void led_display(uint dat,uchar num);

#endif

/************C file of led digital tube display function************/
#include "config.h"

//With 0x7f above, there is a decimal point
//Common table
uchar flash table[]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};

void show(uchar j,uchar k)

    led_wei|=0x0F; //If the position is changed, this should also be changed to clear the screen
                    //Common anode and common cathode and high and low level drive are also different
 led_wei&=~BIT(k);
 /*if(k==1) //This is used to add a decimal point to the required position
 {
   led_duan=table[j]&0x7f;
   delayms(4);
 }*/
 led_duan=table[j];
 delayms(4);
}

/*****************Digital tube output function****************/
void led_display(uint dat,uchar num)//dat is the number to be output, num is the number of digits to be output
{    
  uchar i,ad[4];
     led_duan_ddr;     
     led_wei_ddr;  
   for(i=0;i    {
     ad[i]=dat%10;
  dat=dat/10;
   }
   for(i=0;i    {  
      show(ad[i],i);
   delayms(1);       
   }
   
}

 

/****************Delay function related file******************/
#ifndef __delay_H__
#define __delay_H__

extern void delayms(uint t);

#endif

 

/**************C file of one millisecond delay function********************/
#include "config.h"

/*********One millisecond delay function**********/
void delayms(uint t)
{
    uint i,j;
 for(i=0;i    {
     for(j=0;j<1141;j++);
   }
}

 

/***************Total header file*******************/
#ifndef __config_H__
#define __config_H__

#include
#include

#define uchar unsigned char 
#define uint unsigned int

#include "delay.h"
#include "led.h"

#endif

 

/****************C file of the main function****************************/
#include "config.h"

void main()
{
   while(1)
     {
       led_display(1234,4);
     }
}

Keywords:AVR  ATMEGA128  ATMEGA16 Reference address:AVR (ATMEGA128/ATMEGA16) digital tube display

Previous article:Simple light-seeking car (including multi-channel AD sampling)
Next article:A simple 18B20 program

Recommended ReadingLatest update time:2024-11-16 12:43

Introduction to IO port operation methods of PIC microcontroller, 51 microcontroller and AVR microcontroller
Many friends are always passionate about learning pic microcontrollers, and constantly use their spare time to study various technologies of pic microcontrollers. When talking about pic microcontrollers, 51 and AVR microcontrollers must be involved. Therefore, this article will discuss the operation of IO ports of pic
[Microcontroller]
Introduction to IO port operation methods of PIC microcontroller, 51 microcontroller and AVR microcontroller
ATmega128 system module, design a CNC engraving machine system
In order to realize the control of mini CNC engraving machine, a design scheme of mini CNC engraving machine system based on ATmega128 is proposed, and the hardware circuit design and software design of the system are completed. The hardware circuit design part of the system mainly includes the power supply voltage co
[Microcontroller]
ATmega128 system module, design a CNC engraving machine system
AVR on-chip ADC experiment
  Channel 3 current conversion value 768;        #include iom16v.h #include macros.h //#include math.h //#include stdio.h #include "1602.h" float num ={0,0,0,0,0,0,0,0}; uint addr=0x0000; fly channel=0,i=48; #pragma data:code  const uchar SHAPE ={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
[Microcontroller]
AVR on-chip ADC experiment
Configuration settings of AVR fuse bits
Users can configure the fuse bits of AVR using parallel programming, ISP programming, and JTAG programming, but different programming tool software provide different configuration methods for fuse bits (referring to the human-machine interface). Some are by directly filling in the fuse bit values ​​(such as: CVAVR, Po
[Microcontroller]
atmega128 AD conversion program
/*************************************Include header file********************************/ #include iom128v.h #include macros.h /************************************Digital tube segment code table*******************************/ extern const unsigned char tab ={0x3f,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,       
[Microcontroller]
AVR MCU Power Management_Sleep Mode (Low Power Mode) Experiment
Please read the chip manual first. This is a brief overview of power and sleep modes, and describes the processing when entering the mode and after waking up (be sure to absorb the second paragraph carefully). This is the setting of the control register to enter different modes, entering different modes as needed. Aft
[Microcontroller]
AVR Development Notes - Fuse Positions
1. First, HSE_VALUE in stm32f10x.h #if !defined  HSE_VALUE    #ifdef STM32F10X_CL    #define HSE_VALUE ((uint32_t)12000000) //Change to 12MHz here   //  #define HSE_VALUE    ((uint32_t)25000000) /*! Value of the External oscillator in Hz */注释掉    #else      #define HSE_VALUE    ((uint32_t)8000000) /*! Value of the E
[Microcontroller]
Simulation and Design of AVR Processor on VLSI Platform
  With the development of society, industrial control and people's daily life are increasingly pursuing precision control. To meet this demand, microcontrollers have developed rapidly. Microcontrollers ( MCU ) are also called single-chip microcontrollers or single-chip microcomputers . With the development of large-sca
[Microcontroller]
Simulation and Design of AVR Processor on VLSI Platform
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号