I2C_Communication
1.0
Main Page
Files
File List
File Members
start.cpp
Go to the documentation of this file.
1
16
#include <Arduino.h>
17
#include "LiquidCrystal.h"
18
//#define DEBUG_LCD
19
#include "_debug.h"
20
#include "Wire.h"
21
#include "twi.h"
// required by Wire.h
22
23
#define SA 4
24
//SA ... Slave Address
25
26
void
receiveEvent
(
int
);
//prototype
27
LiquidCrystal lcd(8, 9, 4, 5,6, 7);
//setup Display
29
void
setup
() {
30
Wire.begin(SA);
// join i2c bus as slave with address #4
31
Wire.onReceive(
receiveEvent
);
// register event
32
lcd.begin(16,2);
33
}
34
36
void
loop
() {
37
delay(100);
38
}
39
42
void
receiveEvent
(
int
howMany) {
43
lcd.clear();
//clear display
44
while
(1 < Wire.available()) {
// loop through all but the last
45
char
c = Wire.read();
// receive byte as a character
46
lcd.print(c);
// print the character
47
}
48
int
x = Wire.read();
// receive byte as an integer
49
lcd.print(x);
// print the integer
50
}
51
52
53
receiveEvent
void receiveEvent(int)
Definition:
start.cpp:42
loop
void loop()
Definition:
start.cpp:36
setup
void setup()
Definition:
start.cpp:29
Generated by
1.8.11