简体   繁体   English

如何使用 C 语言遍历 ARM AT91SAM7S256 微控制器中的 LED 列表

[英]How to iterate through a list of LEDs in ARM AT91SAM7S256 Microcontoller using C Language

I am writing a code for the ARM AT91SAM7S256 Microcontoller.我正在为 ARM AT91SAM7S256 微控制器编写代码。 I am trying to turn on the LED randomly.我正在尝试随机打开 LED。

Up until now, I have initialised the LEDS in an array.到目前为止,我已经在一个数组中初始化了 LED。

My array is我的数组是

short leds [] = {LED1, LED2, LED3, LED4, LED5, LED6, LED7, LED8};

The code line to set the led on is设置 LED 的代码行是

SetLEDcolor(LEDNumber, RED);

The value of LEDNumber should come randomly from the array. LEDNumber的值应随机来自数组。

srand(time(NULL));

int ix = rand() % (sizeof(leds)/sizeof(*leds));
SetLEDcolor(leds[ix], RED);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM