Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
dmpada
/
eriala-2024
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9a4348a5
authored
Oct 07, 2024
by
Risto Heinsar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added wk 5 demo codes
parent
9693399c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
lab5/lab5_demo_interrupt/lab5_demo_interrupt.ino
lab5/lab5_demo_ir_capture/lab5_demo_ir_capture.ino
lab5/lab5_demo_interrupt/lab5_demo_interrupt.ino
0 → 100644
View file @
9a4348a5
#define BUTTON_PIN 2
#define STATUS_LED_PIN 7
const
uint8_t
debounceDelay
=
100
;
volatile
bool
robotEnabled
=
true
;
void
setup
()
{
/* Surunupp */
pinMode
(
BUTTON_PIN
,
INPUT
);
/* Roboti seisundi LED */
pinMode
(
STATUS_LED_PIN
,
OUTPUT
);
/* Konfigureerime katkestuse nupu langevale äärele */
attachInterrupt
(
digitalPinToInterrupt
(
BUTTON_PIN
),
RobotPower
,
FALLING
);
}
void
loop
()
{
digitalWrite
(
STATUS_LED_PIN
,
robotEnabled
);
}
void
RobotPower
(
void
)
{
static
uint32_t
lastDebounceTime
=
0
;
/* stabiliseerimismehhanism, et nupu häiringuid vähendada */
if
((
millis
()
-
lastDebounceTime
)
>
debounceDelay
)
{
lastDebounceTime
=
millis
();
robotEnabled
=
!
robotEnabled
;
}
}
\ No newline at end of file
lab5/lab5_demo_ir_capture/lab5_demo_ir_capture.ino
0 → 100644
View file @
9a4348a5
/* IRRemote teek vajab dekodeerimise makrot enne teegi lisamist */
#define DECODE_SAMSUNG
#include <IRremote.hpp>
#define LEFT_LED_PIN 7
#define IR_RECEIVE_PIN 10
void
setup
()
{
Serial
.
begin
(
9600
);
/* IR seadistamine koos seisundi LEDi määramisega */
IrReceiver
.
begin
(
IR_RECEIVE_PIN
,
ENABLE_LED_FEEDBACK
,
LEFT_LED_PIN
);
}
void
loop
()
{
if
(
IrReceiver
.
decode
())
{
/* Alustame järgmise paketi kuulamist enne töötlust (reageerib paremini) */
IrReceiver
.
resume
();
/* Kontrollime kas samsungi IR pakett */
if
(
IrReceiver
.
decodedIRData
.
protocol
==
SAMSUNG
)
{
/* Väljastame dekodeeritud paketi ja saadame üle jadaühenduse */
IrReceiver
.
printIRResultShort
(
&
Serial
);
}
}
}
\ No newline at end of file
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