source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/libraries/Wire/examples/slave_sender/slave_sender.ino @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

File size: 702 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
15void setup() {
16  Wire.begin(8);                // join i2c bus with address #8
17  Wire.onRequest(requestEvent); // register event
18}
19
20void loop() {
21  delay(100);
22}
23
24// function that executes whenever data is requested by master
25// this function is registered as an event, see setup()
26void requestEvent() {
27  Wire.write("hello "); // respond with message of 6 bytes
28  // as expected by master
29}
Note: See TracBrowser for help on using the repository browser.