Commit 966b3fca028e889d4a7f9db66789578682d693cd
1 parent
b3e78c20
envoie 1er juin avec debut arduino
Showing
6 changed files
with
77 additions
and
0 deletions
Show diff stats
No preview for this file type
No preview for this file type
No preview for this file type
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +///////////////////////////// arduino /////////////////////////// | ||
2 | + | ||
3 | +Arès le branchement | ||
4 | +avec la commande | ||
5 | + | ||
6 | +ls -l /dev/*tty* | ||
7 | + | ||
8 | + | ||
9 | +crw-rw---- 1 root dialout 166, 0 juin 1 09:56 /dev/ttyACM0 | ||
10 | + | ||
11 | +le programme d'allumage de led a été réalisé avec succes | ||
12 | + | ||
13 | + |
@@ -0,0 +1,46 @@ | @@ -0,0 +1,46 @@ | ||
1 | + | ||
2 | +#include <stdlib.h> | ||
3 | +#include <stdio.h> | ||
4 | +#include <string.h> | ||
5 | +#include <unistd.h> | ||
6 | +#include <sys/types.h> | ||
7 | +#include <sys/stat.h> | ||
8 | +#include <fcntl.h> | ||
9 | + | ||
10 | +int main(void) | ||
11 | +{ | ||
12 | + | ||
13 | +char car; | ||
14 | +char a; | ||
15 | + | ||
16 | +int ard = open("/dev/ttyACM0",O_RDWR); | ||
17 | + | ||
18 | + while(1) | ||
19 | + { | ||
20 | + read(ard, &car, 1); | ||
21 | + printf ("%c",car); | ||
22 | + | ||
23 | + switch(car) { | ||
24 | + | ||
25 | + case 'A': | ||
26 | + a = '1'; | ||
27 | + break; | ||
28 | + case 'B': | ||
29 | + a = '6'; | ||
30 | + break; | ||
31 | + case 'C': | ||
32 | + a = '3'; | ||
33 | + break; | ||
34 | + case 'D': | ||
35 | + a = '4'; | ||
36 | + break; | ||
37 | + case 'E': | ||
38 | + a = '5'; | ||
39 | + break; } | ||
40 | + | ||
41 | + write(ard,&a,1); | ||
42 | + } | ||
43 | + close(ard); | ||
44 | +} | ||
45 | + | ||
46 | + |