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.
Diff: main.cpp
- Revision:
- 1:df2444f34fec
- Parent:
- 0:2db41a0c2f17
diff -r 2db41a0c2f17 -r df2444f34fec main.cpp
--- a/main.cpp Tue Jan 13 15:48:33 2015 +0000
+++ b/main.cpp Mon Feb 15 17:20:16 2021 +0000
@@ -1,5 +1,4 @@
#include "mbed.h"
-#include "TextLCD.h"
#define Device_Name_ADDR (0xEE) // Device You Wish to Use Address - using i2c Address
#define WRITE (0x00) // i2c Write bit
@@ -16,26 +15,18 @@
I2C i2c(I2C_SDA, I2C_SCL); //I2C Class Pin Assignments see I2C.h
-Serial pc(SERIAL_TX, SERIAL_RX); //Serial Class Pin Assignments see Serial.h
-
-TextLCD lcd(D2,D3,D4,D5,D6,D7); //Text LCD Class assignments RS, E, D4 to D7 see TextLCD.h
-
-char ucdata_write[2];
-short count=0;
-
int main()
{
- unsigned int uibaudrate=115200;
- pc.baud(uibaudrate);
+
+ char ucdata_write[2];
+ short count=0;
unsigned int uifrequency=400000; //400KHz for i2c Max
i2c.frequency (uifrequency);
- pc.printf("\n\rHello World ");
- pc.printf("at %u BAUD and %uKHz i2c Frequency\n\r",uibaudrate,uifrequency/1000);
- pc.printf("Using mbed.org Martin\n\r");
-
- lcd.cls();lcd.locate(0,0); //Tidy up LCD Display
+ printf("\n\rHello World ");
+ printf("at %uKHz i2c Frequency\n\r",uifrequency/1000);
+ printf("Using mbed.org Martin\n\r");
ucdata_write[0]=0;ucdata_write[1]=0;
@@ -43,9 +34,8 @@
{
if (!i2c.write((Device_Adress|WRITE), ucdata_write, 1, 0))// Check for ACK from i2c Device NB I am 'ORing' the Write Bit
{
- pc.printf("ACK from the Device at Address %#4x\n\r",Device_Adress);
- lcd.printf("ACK at:%#4x\n",Device_Adress);
- count=count+1;
+ printf("ACK from the Device at Address %#4x\n\r",Device_Adress);
+ count++;
wait(2);
}
else
@@ -55,6 +45,5 @@
//lcd.printf("No ACK from\nDevice!");
}
}
- pc.printf("\n\r %d Devices have been detected!\n\r",count);
- lcd.printf("%d Dev Found!",count);
+ printf("\n\r %d Devices have been detected!\n\r",count);
}