Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LAB11_Oppgave1 by
main.cpp@0:81fa0e3e8a6c, 2015-11-09 (annotated)
- Committer:
- rlanghbv
- Date:
- Mon Nov 09 13:39:59 2015 +0000
- Revision:
- 0:81fa0e3e8a6c
- Child:
- 1:2d9d32fc4f5d
First Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rlanghbv | 0:81fa0e3e8a6c | 1 | #include "mbed.h" |
rlanghbv | 0:81fa0e3e8a6c | 2 | |
rlanghbv | 0:81fa0e3e8a6c | 3 | //SDA , SCL |
rlanghbv | 0:81fa0e3e8a6c | 4 | I2C i2cBus(PB_9, PB_8); |
rlanghbv | 0:81fa0e3e8a6c | 5 | |
rlanghbv | 0:81fa0e3e8a6c | 6 | int main() |
rlanghbv | 0:81fa0e3e8a6c | 7 | { |
rlanghbv | 0:81fa0e3e8a6c | 8 | i2cBus.frequency(100000); |
rlanghbv | 0:81fa0e3e8a6c | 9 | |
rlanghbv | 0:81fa0e3e8a6c | 10 | //Scan the valid I2C addresrange: 0x3 to 0x77 |
rlanghbv | 0:81fa0e3e8a6c | 11 | for (int i2cAddres=3; i2cAddres<=0x77; i2cAddres++) { |
rlanghbv | 0:81fa0e3e8a6c | 12 | if (!i2cBus.write(i2cAddres<<1, NULL, 0)) { // 0 if a device ACK'ed the message |
rlanghbv | 0:81fa0e3e8a6c | 13 | printf("\r\nI2C device found at address 0x%02X \r\n", i2cAddres); |
rlanghbv | 0:81fa0e3e8a6c | 14 | } |
rlanghbv | 0:81fa0e3e8a6c | 15 | } |
rlanghbv | 0:81fa0e3e8a6c | 16 | } |
rlanghbv | 0:81fa0e3e8a6c | 17 |