.

Dependencies:   C12832 LM75B

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "EthernetInterface.h"
00003 #include "C12832.h"
00004 #include "LM75B.h"
00005 // Using Arduino pin notation
00006 C12832 lcd(D11, D13, D12, D7, D10);
00007 DigitalOut led(LED1);
00008 LM75B sensor(D14,D15);
00009 
00010 int main()
00011 {
00012     lcd.printf("PeerToPeer\n\r");
00013     lcd.printf("Temp = %.1f\n", sensor.read());
00014     EthernetInterface eth;
00015     eth.set_network("192.168.0.07","255.255.255.0","192.168.0.1");
00016     eth.connect();
00017 
00018     printf("The client IP address is '%s'\n\r", eth.get_ip_address());
00019 
00020 
00021     TCPSocket socket;
00022 
00023     socket.open(&eth);
00024     socket.connect("192.168.0.19",4000);
00025     
00026     uint16_t temp = sensor.read();
00027     char upperbyte =(temp>>8) & 0xFF;
00028     char lowerbyte = temp & 0xFF;
00029     char data[2] = {upperbyte, lowerbyte};
00030     printf("The data is: %c\n", data[0]);
00031     socket.send(data,2);
00032     socket.close();
00033 
00034 }
00035 
00036