AVR MCU LED Experiment

Publisher:cloudy德德Latest update time:2012-09-14 Source: 51heiKeywords:AVR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
I bought an AVR128 development board online two days ago. It is really powerful and the online hardware simulation is super cool. The engineers on the website are very easy to talk to. If there is a problem, I will send a text message and call from Harbin to solve it immediately. The AVR port definition is a bit troublesome. I just came from 51 and I am not used to it. However, I know C programming and basically there is no problem.
This is a program to light up the LEDs one by one. It uses the WIN-GCC compiler.

#include 
#include 
#define F_CPU 7372800 /* The main frequency of the MCU is 7.3728MHz, used for the delay subroutine*/
#include 
#include 

#define delay_us(x) _delay_us(x) //AVR GCC delay function x(us)
#define delay_ms(x) _delay_ms(x) //AVR GCC delay function x(ms)


void main()
{   
    PORTA=0xff; //Close the digital tube port to avoid garbled characters on the digital tube
    PORTB=0xfe; //Set the output value of port PB
    DDRB=0xFF; //Define PB port as output mode
    unsigned char i;
 while(1)
 {   
    i=PORTB;
       for(i=0;i<8;i++)
   {  
    PORTB=PORTB<<1;
    delay_ms(500);
    }
    PORTB=0xff;
    delay_ms(500);
 }
}
Keywords:AVR Reference address:AVR MCU LED Experiment

Previous article:Design of digital frequency meter based on single chip microcomputer
Next article:AVR learning air conditioner infrared remote control code

Recommended ReadingLatest update time:2024-11-16 18:03

Design of soybean milk machine based on SH69P42 single chip microcomputer
Aiming at the problem of long pulping time, this paper designs an efficient and time-saving soymilk machine based on SH69P42 single- chip microcomputer. On the basis of maintaining the structure and function of the existing soymilk machine, the soymilk machine installs a simple defoaming devic
[Microcontroller]
Design of soybean milk machine based on SH69P42 single chip microcomputer
PIC microcontroller C language programming (8)
  2. Installation of PICC compiler.   When the article "PIC Microcontroller C Language Program (7)" introduced the installation of MPLAB IDE7.40, we pasted the compressed software PICC8.05.rar (see Figure 12 of the article) of the PICC compiler in the CD to the E disk of "My Computer". So when installing the PICC co
[Microcontroller]
PIC microcontroller C language programming (8)
Design of an intelligent traffic monitoring system based on MCU
1 Introduction In the process of industrial production, the measurement of various flowing media and the accurate measurement of flow have become an important content in the current industrial measurement and control systems, energy measurement management and other fields. At the same time, the petrochemical, food a
[Microcontroller]
Design of an intelligent traffic monitoring system based on MCU
51 MCU Experiment 5: Dynamic Digital Tube
The circuit diagram of the digital tube module of the development board is as follows: Due to the characteristics of the 74ls138 decoder, that is, only one digital tube can have a cathode level of 0, it is obviously impossible to make multiple digital tubes work at the same time. If you want to get the effect of mul
[Microcontroller]
51 MCU Experiment 5: Dynamic Digital Tube
8.STC15W408AS MCU Timer/Counter
1. Introduction to timer counter STC15W408AS has only timer 0 and timer 2, working in timer or counter mode. The core component of the timer/counter is an adder counter, which essentially counts pulses. The only difference is the source of the counting pulse: if the counting pulse comes from the system clock, it is a
[Microcontroller]
8.STC15W408AS MCU Timer/Counter
41-Intelligent water heater control system based on 51 single chip microcomputer
Specific implementation functions The system consists of STC89C52 single chip microcomputer + water level detection sensor + DS18B20 temperature probe sensor + button module + relay module + alarm and indication module + LCD1602 display module + power supply. Specific functions: 1. The first line of the LCD1602 di
[Microcontroller]
41-Intelligent water heater control system based on 51 single chip microcomputer
Implementation of Serial Port Protocol Networking Using Single Chip Microcomputer
The RAM area of ​​the network card is shown in Figure 2. When we set PSTART and PSTOP, the receiving area is determined to be between 46 and 7F, and the remaining 6 pages are used as the sending buffer, which can meet the requirement of sending the maximum Ethernet data packet with a capacity of 1514 bytes at a time. T
[Industrial Control]
Implementation of Serial Port Protocol Networking Using Single Chip Microcomputer
How to use 51 single-chip microcomputer return? How to use single-chip microcomputer return
Function writing 1: u8 is_timeout(tick start_time, tick interval) { return (get_diff_tick(get_tick(), start_time) interval); } Function writing 2: u8 is_timeout(tick start_time, tick interval) { u8 status; status = get_diff_tick(get_tick(), start_time) interval); return status; } Function calling
[Microcontroller]
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号