Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이다은
/
raspberry
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
daeun
2021-04-22 21:53:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ec9898e58bbf1c3166a77b4b19bc994f39b3b1e0
ec9898e5
1 parent
b640b4be
modify
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
assignment/lab2-3-2(new).c
assignment/lab2-3-2(new).c
View file @
ec9898e
...
...
@@ -2,11 +2,13 @@
#include <wiringPi.h>
const
int
LedRed
[
8
]
=
{
4
,
17
,
18
,
27
,
22
,
23
,
24
,
25
};
const
int
Keypad
[
5
]
=
{
6
,
12
,
13
,
16
,
19
};
int
state
=
0
;
int
KeypadRead
()
{
int
i
,
keypadnum
=
-
1
;
for
(
i
=
0
;
i
<
2
;
i
++
)
{
if
(
!
digitalRead
(
Keypad
[
i
]))
{
state
=
1
;
keypadnum
=
i
;
break
;
}
}
...
...
@@ -24,6 +26,7 @@ void LedControl(int num)
}
void
stop
()
{
LedControl
(
-
1
);
state
=
0
;
}
int
main
(
void
)
{
...
...
@@ -45,23 +48,28 @@ int main(void)
if
(
keypadnum
==
0
)
{
while
(
1
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
if
(
state
==
0
)
break
;
LedControl
(
i
);
delay
(
500
);
}
digitalWrite
(
LedRed
[
i
-
1
],
LOW
);
if
(
state
==
0
)
break
;
}
}
else
if
(
keypadnum
==
1
)
{
while
(
1
)
{
for
(
i
=
7
;
i
>=
0
;
i
--
)
{
if
(
state
==
0
)
break
;
LedControl
(
i
);
delay
(
500
);
}
digitalWrite
(
LedRed
[
i
+
1
],
LOW
);
if
(
state
==
0
)
break
;
}
}
if
(
keypadnum
==
3
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
if
(
state
==
0
)
break
;
LedControl
(
i
);
delay
(
500
);
}
...
...
@@ -69,6 +77,7 @@ int main(void)
}
else
if
(
keypadnum
==
4
)
{
for
(
i
=
7
;
i
>=
0
;
i
--
)
{
if
(
state
==
0
)
break
;
LedControl
(
i
);
delay
(
500
);
}
...
...
Please
register
or
login
to post a comment