BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
arduino_i2c_keyboard
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
arduino_i2c_keyboard
Commits
a50e2be3
Commit
a50e2be3
authored
Jul 01, 2018
by
Forest Godfrey
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://gitlab.bigw.org:766/fgodfrey/arduino_i2c_keyboard
parents
80d952e3
b410d813
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
arduino_sketch.ino
arduino_sketch/arduino_sketch.ino
+50
-0
No files found.
arduino_sketch/arduino_sketch.ino
0 → 100644
View file @
a50e2be3
#include <Wire.h>
#define INTERRUPT_PIN 9
#define I2C_ADDRESS 0x42
unsigned
long
next_send_intr
;
int
current_intr_val
;
void
i2cReceive
(
int
bytes
)
{
Serial
.
print
(
"Bytes available: "
);
Serial
.
println
(
bytes
);
while
(
1
<
Wire
.
available
())
{
// loop through all but the last
char
c
=
Wire
.
read
();
// receive byte as a character
Serial
.
print
(
c
);
// print the character
}
int
x
=
Wire
.
read
();
// receive byte as an integer
Serial
.
println
(
x
);
// print the integer
}
void
setup
()
{
// Initialize console
Serial
.
begin
(
9600
);
Serial
.
println
(
"Arduino I2C Keyboard Driver Built "
__DATE__
" "
__TIME__
);
// Initialize Interrupt Pin
digitalWrite
(
INTERRUPT_PIN
,
1
);
pinMode
(
INTERRUPT_PIN
,
OUTPUT
);
// Initialize I2C Slave Interface
Wire
.
begin
(
I2C_ADDRESS
);
// join i2c bus with address #8
Wire
.
onReceive
(
i2cReceive
);
next_send_intr
=
0
;
current_intr_val
=
1
;
}
void
loop
()
{
// put your main code here, to run repeatedly:
if
(
millis
()
>
next_send_intr
)
{
current_intr_val
=
current_intr_val
?
0
:
1
;
digitalWrite
(
INTERRUPT_PIN
,
current_intr_val
);
next_send_intr
=
millis
()
+
5000
;
Serial
.
print
(
"Interupt pin now "
);
Serial
.
println
(
current_intr_val
);
}
delay
(
10
);
}
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