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 MAX11410-test by
Diff: main.cpp
- Revision:
- 2:39ba9beabf3c
- Parent:
- 1:1cdd12a4efb2
- Child:
- 3:42120705a9bd
--- a/main.cpp Mon Oct 10 21:28:26 2016 +0000
+++ b/main.cpp Wed Nov 09 01:31:22 2016 +0000
@@ -6,20 +6,28 @@
// - for every device if finds, it prints the 8-bit address
// - if the program hangs, the bus isn't working (check pull-ups etc)
// - if it doesn't find your device, check power/bus wiring etc
-
+
#include "mbed.h"
I2C i2c(I2C_SDA, I2C_SCL); // sda, scl
+Ticker repeatTicker;
-int main() {
+void repeat()
+{
printf("I2CU! Searching for I2C devices...\n");
int count = 0;
for (int address=0; address<256; address+=2) {
- if (!i2c.write(address, NULL, 0)) { // 0 returned is ok
+ bool temp = i2c.write(address, NULL, 0); // 0 if successful, otherwise non-zero
+ if (!temp && (address >> 1) != 0) { // not interested in address 0
printf(" - I2C device found at address 0x%02X\n", address >> 1);
count++;
}
}
- printf("%d devices found\n", count);
+ printf("%d device(s) found\n", count);
}
+
+int main()
+{
+ repeatTicker.attach(&repeat, 2.0);
+}
\ No newline at end of file
