microcontrolador digitales2
/
i2cesclavo
JHKLJHKJLHKL
main.cpp@0:50b9be5874c2, 2022-03-19 (annotated)
- Committer:
- juanespitiarobotica
- Date:
- Sat Mar 19 16:31:38 2022 +0000
- Revision:
- 0:50b9be5874c2
CHHG
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
juanespitiarobotica | 0:50b9be5874c2 | 1 | #include "mbed.h" |
juanespitiarobotica | 0:50b9be5874c2 | 2 | #include "I2CSlave.h" |
juanespitiarobotica | 0:50b9be5874c2 | 3 | |
juanespitiarobotica | 0:50b9be5874c2 | 4 | using namespace std; |
juanespitiarobotica | 0:50b9be5874c2 | 5 | |
juanespitiarobotica | 0:50b9be5874c2 | 6 | Serial pc(USBTX, USBRX);//-----serial monitor connection |
juanespitiarobotica | 0:50b9be5874c2 | 7 | I2CSlave slave(PTC9,PTC8); //Configure I2C slave |
juanespitiarobotica | 0:50b9be5874c2 | 8 | DigitalOut LD(D2); //-----------LD Toggle on/off---------[D2 pin5] |
juanespitiarobotica | 0:50b9be5874c2 | 9 | char i2c; |
juanespitiarobotica | 0:50b9be5874c2 | 10 | |
juanespitiarobotica | 0:50b9be5874c2 | 11 | |
juanespitiarobotica | 0:50b9be5874c2 | 12 | int main() { |
juanespitiarobotica | 0:50b9be5874c2 | 13 | slave.address(0x05); |
juanespitiarobotica | 0:50b9be5874c2 | 14 | printf("STM STARTING/r/n"); |
juanespitiarobotica | 0:50b9be5874c2 | 15 | printf("STM Ready/r/n"); |
juanespitiarobotica | 0:50b9be5874c2 | 16 | while(1){ |
juanespitiarobotica | 0:50b9be5874c2 | 17 | i2c = slave.read(); |
juanespitiarobotica | 0:50b9be5874c2 | 18 | printf("%c",i2c); |
juanespitiarobotica | 0:50b9be5874c2 | 19 | |
juanespitiarobotica | 0:50b9be5874c2 | 20 | } |
juanespitiarobotica | 0:50b9be5874c2 | 21 | } |