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.
Dependencies: HTTPClient WIZnetInterface mbed
Fork of dweetIo_CloudService_Helloworld_WIZwiki- by
Revision 3:9000aa421555, committed 2015-09-14
- Comitter:
- joon874
- Date:
- Mon Sep 14 23:39:51 2015 +0000
- Parent:
- 2:4d82eafe860d
- Child:
- 4:17ef6f06e4b5
- Commit message:
- edit code for academy
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Sep 14 05:52:50 2015 +0000
+++ b/main.cpp Mon Sep 14 23:39:51 2015 +0000
@@ -2,31 +2,29 @@
#include "EthernetInterface.h"
#include "HTTPClient.h"
+/*
+ SET DHCP
+*/
#define USE_DHCP 1
+
unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x12,0x34,0x56};
-char IP_Addr[] = "192.168.0.100";
-char IP_Subnet[] = "255.255.255.0";
-char IP_Gateway[] = "192.168.0.1";
-Serial pc(USBTX, USBRX);
-/******************
-VCC A0 GND
- | | |
- | | |
- | | |
- | | |
- --10k-----CDS---
-*******************/
+/* IP SET */
+//char IP_Addr[] = "192.168.0.100";
+//char IP_Subnet[] = "255.255.255.0";
+//char IP_Gateway[] = "192.168.0.1";
+
+Serial pc(USBTX, USBRX);
EthernetInterface ethernet;
-AnalogIn CDSSensor(A0);
+AnalogIn Sensor(A0);
int main() {
/// mbed_mac_address((char *)MAC_Addr); //Use mbed mac addres
- pc.baud(115200);
+ pc.baud(9600);
#if USE_DHCP
int ret = ethernet.init(MAC_Addr);
#else
@@ -48,21 +46,21 @@
}
char str[512];
- char get_msg[128]= "";
+ char msg[128]= "";
/*
http://dweet.io/follow/nameYouWant
*/
char nameYouWant[] = "nameYouWant";
- //char nameYouWant[] = "sep152015test";
+
while(1)
{
- sprintf(get_msg,"http://dweet.io/dweet/for/%s?a0=%d",nameYouWant,(int)(CDSSensor.read()*1000));
+ sprintf(msg,"http://dweet.io/dweet/for/%s?a0=%d",nameYouWant,(int)(Sensor.read()*1000));
HTTPClient http;
pc.printf("Send post message to dweet.io\r\n");
- pc.printf("msg : %s\r\n",get_msg);
- ret = http.get(get_msg, str, sizeof(str));
+ pc.printf("msg : %s\r\n",msg);
+ ret = http.get(msg, str, sizeof(str));
if(!ret)
{
pc.printf("\r\nPage fetched successfully - read %d characters\r\n", strlen(str));
