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.
main.cpp
00001 #include "mbed.h" 00002 00003 I2C i2c(I2C_SDA, I2C_SCL); 00004 00005 int main(){ 00006 printf("\nI2C Scanner running...\n"); 00007 //i2c.frequency(400000); 00008 int error, address, nDevices; 00009 nDevices = 0; 00010 for(address = 0; address < 128; address++ ){ 00011 thread_sleep_for(10); 00012 error = i2c.write(address << 1, "1", 1); 00013 00014 if (error == 0){ 00015 printf("I2C device found at address 8bit: 0x%X 7bit: 0x%X\n", address, address << 1); 00016 nDevices++; 00017 } 00018 } 00019 if (nDevices == 0){ 00020 printf("No I2C devices found\n"); 00021 }else{ 00022 printf("\ndone\n"); 00023 } 00024 }
Generated on Wed Nov 16 2022 14:17:43 by
1.7.2