嵌入式跑马灯实验报告(跑马灯课程设计实验报告)

http://www.itjxue.com  2023-02-03 18:05  来源:未知  点击次数: 

单片机89C51用汇编制作跑马灯P1控制8个LED(D1~D8)灯实现流水灯的效果,高手速度来

很酷的流水灯

#include reg51.h

typedef unsigned char uchar;

#define Ton 40

#define LED P0

sbit leds=P1^4;

sbit LED0 = P0^0;

sbit LED1 = P0^1;

sbit LED2 = P0^2;

sbit LED3 = P0^3;

sbit LED4 = P0^4;

sbit LED5 = P0^5;

sbit LED6 = P0^6;

sbit LED7 = P0^7;

unsigned char Maikuan=0;

static unsigned char ledon[8] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};

uchar Occupy_led; //占空比越大,灯越亮

bit light;

uchar m;

void Inittime()

{

TMOD = 0x02; //定时器0,工作方式2,自动重装

TH0 = 256-Ton;

TL0 = 256-Ton;

ET0 = 1;

EA = 1;

TR0 = 1;

}

//定时器0中断

void time0() interrupt 1 using 0

{

Maikuan++;

}

void main()

{

unsigned char i = 0,j = 0; //初始化i,j

leds=0;

Inittime();

while (1)

{

//第1,3,5,7个灯半亮,其余的全亮。

for(i=254; i0; i--)

{

while ( Maikuan!=20)

{

LED = 0x00;

}

while ( Maikuan!=200)

{

LED = 0x55;

}

Maikuan = 0;

}

//最难的:8个灯从第一个开始依次渐亮,直到最后一个。再从最后一个起渐暗,直到第一个。如此循环往复。

for(j = 0;j=7;j++)

{

i = 0;

while(i!=255) // 由暗变亮

{

if( Maikuan == 0) // 点亮

{

LED = ledon[j];

}

if(Maikuan == i) // 熄灭

{

LED = 0xff;

}

if( Maikuan== 255)

{

i++;

}

}

}

for(j=7;j=0;j--)

{

i = 0;

while(i!=255) // 由亮变暗

{

if(Maikuan == 0) // 熄灭

{

LED = 0xff;

}

if( Maikuan == i) // 点亮

{

LED = ledon[j];

}

if( Maikuan == 255)

{

i++;

}

}

}

//所有的灯逐渐从暗到全亮,再由全亮到暗。

for (m=254; m0; m--)

{

while (Maikuan!=Occupy_led)

{

LED = 0x00;

}

while (Maikuan!=127)

{

LED = 0xff;

}

Maikuan = 0;

if (light)

{

Occupy_led++;

}

else

{

Occupy_led--;

}

if (Occupy_led==128)

{

Occupy_led = 127;

light = !light;

}

if (Occupy_led128)

{

Occupy_led = 0;

light = !light;

}

}

}

}

跑马灯的原理

跑马灯实际上运作的方式说穿了很简单,程式先定义一段要展示的原始字串.然后从原始字串中抽取一小段的文字显示出来.每次取这一小段的文字时.都比上次所取时位置稍候.因此造成了卷动的效果.

用51单片机设计一个16位的跑马灯 要求通过一个开关控制3种不同的模式 用汇编语言写,三种模式随意

一个开关,比如导通了1秒一个模式,3秒一个模式,5秒一个模式。

要么在一定时间内,检测开关导通的次数

我觉得应该弄的直观点,从51上接4个led做指示用,一个灯表示待运行,还有3个灯,亮一个表示模式1,亮两个表示模式2,亮3个表示模式3

开机的时候,待运行灯亮,等待设定模式,这时候开始按按键设定模式,同时待运行灯灭。模式灯随按键操作变化。

模式设定好了,停止按键操作,两秒后待运行灯亮,表示模式设定完毕。这时候长按按键,开始跑马灯。短按按键则返回模式设定。

当开始运行跑马灯的时候,可以设定运行一遍返回,也可以中断返回。

个人想法,不知行不行

跑马灯电路设计,led由上至下依次点亮,间隔一秒,再跳回最下边,不断循环显示。

八个灯连至P1,

程序如下:

MOV A,01H

START: MOV P1,A

RL A

CALL DELAY

JMP START

DELAY:......

........

........

RET

END

其中DELAY 是一个延时1S子程序(不要改变A的值),具体要根据单片机的时钟计算延时时间,可以采用循环嵌套的方式,很容易就可以实现。

STM32跑马灯程序如何加入定时器功能

以下代码摘自 正点原子ALIENTEK 战舰 STM32F103 V3 开发板教程 《STM32F1 开发指南(库函数版)》第十三章 定时器中断实验。

#include "timer.h"

//通用定时器 3 中断初始化

//这里时钟选择为 APB1 的 2 倍,而 APB1 为 36M

//arr:自动重装值。

//psc:时钟预分频数

//这里使用的是定时器 3!

void TIM3_Int_Init(u16 arr,u16 psc)

{

TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;

NVIC_InitTypeDef NVIC_InitStructure;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //①时钟 TIM3 使能

//定时器 TIM3 初始化

TIM_TimeBaseStructure.TIM_Period = arr; //设置自动重装载寄存器周期的值

TIM_TimeBaseStructure.TIM_Prescaler =psc; //设置时钟频率除数的预分频值

TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //设置时钟分割

TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIM 向上计数

TIM_TimeBaseInit(TIM3, TIM_TimeBaseStructure); //②初始化 TIM3

TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE ); //③允许更新中断

//中断优先级 NVIC 设置

NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; //TIM3 中断

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //先占优先级 0 级

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //从优先级 3 级

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ 通道被使能

NVIC_Init(NVIC_InitStructure); //④初始化 NVIC 寄存器

TIM_Cmd(TIM3, ENABLE); //⑤使能 TIM3

}

//定时器 3 中断服务程序⑥

void TIM3_IRQHandler(void) //TIM3 中断

{

if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查 TIM3 更新中断发生与否

{

TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //清除 TIM3 更新中断标志

LED1=!LED1;

}

}

求助!帮我翻译下 汉译英 高分悬赏

为了探索商用LED跑马灯的利用价值,真正实现其开发便捷,使用方便,价格低廉的特点,特设计基于嵌入式Linux系统的跑马灯。随着信息时代的走进,嵌入式Linux系统逐渐被人们看好及广泛应用于商用领域,我们通过探索实验得出,做LED跑马灯基于嵌入式Linux系统是便捷、快速、成本小、开发周期短的一个最好办法。本文主要介绍了嵌入式的概况及应用领域,嵌入式Linux系统的概况及发展趋势,还简单的介绍了我们试验中要用到得ARM9实验板的概况,总之在本文中既有嵌入式的软件又有嵌入式硬件方面的内容,都很详细。通过大量前期资料的整理,我们在Linux环境中编译出了LED跑马灯的驱动程序和应用程序,通过交叉编译在ARM9实验板上运行并最终实验测试结果正常,达到我们要实验的目的。结果表明,基于嵌入式Linux系统LED跑马灯的设计与实现,是最便捷,简单,开发周期短的方式。在开发结果我们也看出LED跑马灯用嵌入式Linux系统编译,在Linux系统的开发环境下运行良好,如我们大家所期待达到我们所要求的实验目的,并从中表现出极好的运行性能和安全性能。

Make use of value for probing commercial LED horse race light's , truly put into effect whose exploitation is convenient and rapid , usage goes to the lavatory , the cheap characteristic of price , the secret agent design that owing to implanting dyadic systematic Linux horse race light. With the fact that the information ear walking moves forward, dyadic implantation Linux system is found the commercial field satisfactory and applied to broadly gradually by people, that we reach , make LED horse race light by probing an experiment is convenient and rapid owing to implanting dyadic Linux system , the fleetness , cost develop a short best way of period for a short time. Implant the dyadic general situation and application field that the main body of a book has been introduced mainly , implant the dyadic systematic general situation of Linux and developing trend, unnatural general situation having introduced that we need to use to getting the ARM9 experiment in the experiment fairly simplely, the content both have aspect to implant the dyadic software and have to implant the dyadic hardware in the main body of a book, is in short , all very detailed. Arranging by large amount of the earlier stage data , our driver and application having compiled and translated out LED horse race light in the environment in Linux, that the work and ultimate experiment tests result by intersection compile and translate on ARM9 experiment board is regular , achieve our essential points experiment's purpose.Result is indicated, owing to the design implanting dyadic Linux system LED horse race light and the way coming true , being convenient and rapid , simple , developing a period shortly. We also perceive LED horse race light in the result developing using dyadic implantation Linux system to compile and translate , operation is fine under systematic Linux exploitation environment, if what all of us expects to achieve what our demands experiment purpose, and is extremely good out of runs the function and the safe function.

本文在介绍嵌入式Linux系统的基础上,研究在LED跑马灯方面的应用,引用嵌入式Linux系统跑马灯设计训练过程及测试结果,最后通过交叉编译,实现了基于嵌入式Linux系统的跑马灯设计能够取得比较好的效果。

The systematic basis is listed in the main body of a book in Linux introducing implantation style , is study the application in the field of LED horse race light, the horse race light quoting dyadic implantation Linux system horse race light designing the system training process and testing result , the at last having come true by intersection compile and translate, owing to implanting dyadic Linux designs that being able to get comparatively good effect.

这样就可以了。希望能帮到你。

(责任编辑:IT教学网)

更多

推荐Fireworks教程文章