Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RF24
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
RF24
Commits
3cc856aa
Commit
3cc856aa
authored
Jun 25, 2011
by
maniacbug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the logic. Button press now toggles the LED.
parent
26c45e85
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
examples/led_remote/led_remote.pde
examples/led_remote/led_remote.pde
+12
-4
No files found.
examples/led_remote/led_remote.pde
View file @
3cc856aa
...
...
@@ -81,6 +81,7 @@ role_e role;
//
uint8_t
button_states
[
num_button_pins
];
uint8_t
led_states
[
num_led_pins
];
//
// Setup
...
...
@@ -165,11 +166,12 @@ void setup(void)
// Turn LED's ON until we start getting keys
if
(
role
==
role_led
)
{
int
i
=
num_
button
_pins
;
int
i
=
num_
led
_pins
;
while
(
i
--
)
{
pinMode
(
button_pins
[
i
],
OUTPUT
);
digitalWrite
(
button_pins
[
i
],
HIGH
);
led_states
[
i
]
=
HIGH
;
digitalWrite
(
led_pins
[
i
],
led_states
[
i
]);
}
}
...
...
@@ -236,10 +238,16 @@ void loop(void)
// Spew it
printf
(
"Got buttons
\n\r
"
);
//
Set all the LED's according to the buttons
//
For each button, if the button now on, then toggle the LED
int
i
=
num_led_pins
;
while
(
i
--
)
digitalWrite
(
led_pins
[
i
],
button_states
[
i
]);
{
if
(
button_states
[
i
]
)
{
led_states
[
i
]
^=
HIGH
;
digitalWrite
(
led_pins
[
i
],
led_states
[
i
]);
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment