Last change
on this file since 136 was 136, checked in by ertl-honda, 8 years ago |
ライブラリとOS及びベーシックなサンプルの追加.
|
File size:
723 bytes
|
Line | |
---|
1 | // Wire Slave Sender
|
---|
2 | // by Nicholas Zambetti <http://www.zambetti.com>
|
---|
3 |
|
---|
4 | // Demonstrates use of the Wire library
|
---|
5 | // Sends data as an I2C/TWI slave device
|
---|
6 | // Refer to the "Wire Master Reader" example for use with this
|
---|
7 |
|
---|
8 | // Created 29 March 2006
|
---|
9 |
|
---|
10 | // This example code is in the public domain.
|
---|
11 |
|
---|
12 |
|
---|
13 | #include <Wire.h>
|
---|
14 |
|
---|
15 | void setup()
|
---|
16 | {
|
---|
17 | Wire.begin(2); // join i2c bus with address #2
|
---|
18 | Wire.onRequest(requestEvent); // register event
|
---|
19 | }
|
---|
20 |
|
---|
21 | void loop()
|
---|
22 | {
|
---|
23 | delay(100);
|
---|
24 | }
|
---|
25 |
|
---|
26 | // function that executes whenever data is requested by master
|
---|
27 | // this function is registered as an event, see setup()
|
---|
28 | void requestEvent()
|
---|
29 | {
|
---|
30 | Wire.write("hello "); // respond with message of 6 bytes
|
---|
31 | // as expected by master
|
---|
32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.