⚲
Projet
Général
Profil
Connexion
S'enregistrer
Accueil
Projets
Aide
Recherche
:
Polytech Ge Sous Traitance
Tous les projets
Polytech Projets Ge
»
Polytech Ge Sous Traitance
Aperçu
Activité
Roadmap
Demandes
Gantt
Calendrier
Annonces
Documents
Wiki
Fichiers
Dépôt
Télécharger (996 octets)
Envoie d'un cycle d'affichage entre deux arduino via USB (8octets)
» slave3.ino
Anonyme, 23/11/2021 16:06
#include
<SoftwareSerial.h>
SoftwareSerial
mySerial
(
10
,
11
);
const
unsigned
int
MAX_MESSAGE_LENGTH
=
32
;
int
ledpin
[]
=
{
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
,
51
,
52
,
53
};
void
setup
()
{
Serial
.
begin
(
9600
);
mySerial
.
begin
(
9600
);
for
(
int
c
=
22
;
c
<
54
;
c
++
)
{
pinMode
(
c
,
OUTPUT
);
}
}
void
loop
()
{
while
(
mySerial
.
available
()
>
0
)
{
static
char
message
[
MAX_MESSAGE_LENGTH
];
static
unsigned
int
message_pos
=
0
;
char
inByte
=
mySerial
.
read
();
if
(
inByte
!=
'\n'
&&
(
message_pos
<
MAX_MESSAGE_LENGTH
-
1
)
)
{
message
[
message_pos
]
=
inByte
;
message_pos
++
;
}
else
{
message
[
message_pos
]
=
'\0'
;
mySerial
.
println
(
message
);
for
(
int
p
=
0
;
p
<
33
;
p
++
){
if
(
message
[
p
]
==
'1'
){
digitalWrite
(
ledpin
[
p
+
1
],
1
);
}
else
digitalWrite
(
ledpin
[
p
+
1
],
0
);
}
Serial
.
println
(
message
);
message_pos
=
0
;
}
}
}
« Précédent
1
2
Suivant »
(2-2/2)
Chargement...