当前位置:网站首页>Experiment 6 examination
Experiment 6 examination
2022-06-30 08:03:00 【emplace_ back】
《 Embedded system design 》 The test
Examination requirements :
stay Linux Compiled under the system LED、 Key and buzzer program ,
The object file generated through cross compilation is uploaded to the development board through the serial port ,
And execute the program on the development board and observe the results .
specific requirement :
The initial frequency is 10,LED In the state of total extinction ,
Definition 3 A button ,
Key 1:
Press the key every time to increase the frequency 1,
When the frequency is greater than or equal to 19 Return to the initial value ,
The frequency is increased every time 2 Light up a LED The lamp
( namely : The frequency is 18 when LED In the state of full illumination );
Key 2:
Press the key every time to reduce the frequency 1,
When the frequency is less than or equal to 1 Return to the initial value ,
Each time the frequency decreases 2 One goes out at a time LED The lamp ( Only for LED When on );
Key 3:
Turn off the buzzer 、LED Total destruction 、 And quit the program .
The experimental steps :
A little
Experimental code :
#include<stdio.h>
#include<fcntl.h>
#include<stdlib.h>
int main() {
int fdk, fdp, fdl;
int i;
int frq = 10;
int twice_inc = 0;
int twice_dec = 0;
// Which lamp , Less than which_led Liang Liang
int which_led = 0;
char key[4] = {
'0', '0', '0', '0'};
fdk = open("/dev/buttons", O_RDONLY);
fdp = open("/dev/pwm", O_RDONLY);
fdl = open("/dev/leds",O_WRONLY);
if(fdk<0) {
printf("Open buttons ERROR!\n");
exit(1);
}
if(fdp<0) {
printf("Open PWM ERROR!\n");
exit(1);
}
if(fdl<0) {
printf("Open leds ERROR!\n");
exit(1);
}
for(i = 0; i < 4; i++) ioctl(fdl, 0, i);
// The main program
for(;;) {
char cukey[4] = {
'0', '0', '0', '0'};
read(fdk, cukey, sizeof cukey);
for(i = 0; i < 4; i++) {
if(key[i] != cukey[i]) {
key[i] = cukey[i];
if(key[i] == '1') {
switch(i) {
case 0:
frq++;
twice_dec = 0;
twice_inc++;
if(frq == 19) frq = 10;
if(twice_inc == 2) {
if(which_led != 4) {
ioctl(fdl, 1, which_led);
which_led++;
}
twice_inc = 0;
}
break;
case 1:
frq--;
twice_inc = 0;
twice_dec++;
if(twice_dec == 2) {
if(which_led != 0) {
which_led--;
ioctl(fdl, 0, which_led);
}
twice_dec = 0;
}
if(frq == 1) frq = 10;
break;
case 2:
ioctl(fdp, 0);
for(i = 0; i < 4; i++) ioctl(fdl, 0, i);
close(fdk);
close(fdp);
close(fdl);
exit(1);
break;
default:
printf("Invalid button!\n");
}
ioctl(fdp, 1, frq);
printf("------------------------------\n");
printf("which_led = %d\n", which_led);
printf("twice_inc = %d\ntwice_dec = %d\n", twice_inc, twice_dec);
printf("frq = %d\n", frq);
printf("------------------------------\n\n");
}
}
}
}
return 0;
}
边栏推荐
- December 4, 2021 [metagenome] - sorting out the progress of metagenome process construction
- 为什么大学毕业了还不知道干什么?
- 1163 Dijkstra Sequence
- Go 数据类型篇之字符串及底层字符类型
- 领域驱动下cloud项目中单个服务的示例
- Final review -php learning notes 5-php array
- Calculate Euler angle according to rotation matrix R yaw, pitch, roll source code
- November 16, 2021 [reading notes] - macro genome analysis process
- 深度学习——目标定位
- Lodash filter collection using array of values
猜你喜欢
鲸探NFT数字臧品系统开发技术分享
2021-10-29 [microbiology] a complete set of 16s/its analysis process based on qiime2 tool (Part I)
微信小程序使用vant weapp报错
Deep learning - goal orientation
Final review -php learning notes 5-php array
Arm debug interface (adiv5) analysis (I) introduction and implementation [continuous update]
深度学习——词汇表征
Deep learning - bounding box prediction
Recurrence relation (difference equation) -- Hanoi problem
Vulfocus entry target
随机推荐
【花雕体验】13 搭建ESP32C3之PlatformIO IDE开发环境
mysql无法连接内网的数据库
想转行,却又不知道干什么?此文写给正在迷茫的你
架构实战营模块 5 作业
Lodash filter collection using array of values
1163 Dijkstra Sequence
2022.01.20 [bug note] | qiime2: an error was encoded while running dada2 in R (return code 1)
February 14, 2022 [reading notes] - life science based on deep learning Chapter 2 Introduction to deep learning (Part 1)
Why don't you know what to do after graduation from university?
Introduction to opencv (I): image reading and display
Permutation and combination of probability
Final review -php learning notes 4-php custom functions
[tensorflow GPU] building of deep learning environment under windows11
1162 Postfix Expression
Tue Jun 28 2022 15:30:29 gmt+0800 (China standard time) date formatting
The counting tool of combinatorial mathematics -- generating function
July 30, 2021 [wgs/gwas] - whole genome analysis process (Part I)
Deep learning - bounding box prediction
right four steps of SEIF SLAM
[flower carving experience] 14 line blank board pingpong library test external sensor module (one)