![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
PLC
Dependencies: EthernetNetIf HTTPServer TextLCD mbed
Fork of ethernet_test_http by
main.cpp
- Committer:
- twinkling
- Date:
- 2014-05-12
- Revision:
- 1:7097c8844b71
- Parent:
- 0:7dcfd77d344d
File content as of revision 1:7097c8844b71:
#include "mbed.h" #include "TextLCD.h" #include "EthernetNetIf.h" #include "HTTPServer.h" #include "adc.h" DigitalOut led1(LED1,"led1"); DigitalOut led2(LED2,"led2"); DigitalOut led3(LED3,"led3"); DigitalOut led4(LED4,"led4"); InterruptIn pin5(p5); TextLCD lcd(p24, p26, p27, p28, p29, p30); EthernetNetIf ethif(IpAddr(192,168,11,26), IpAddr(255,255,255,0), IpAddr(192,168,11,1), IpAddr(192,168,11,1)); HTTPServer server; LocalFileSystem local("local"); FILE *fp; void int_rise() { led4 = 1; if ( NULL == (fp = fopen( "/local/test.txt", "w" )) ) error( "" ); fprintf( fp, "st detect"); lcd.locate(0,1); lcd.printf("Detect"); wait( 0.1 ); fclose( fp ); } void int_fall() { led4 = 0; if ( NULL == (fp = fopen( "/local/test.txt", "w" )) ) error( "" ); fprintf( fp, "%st undetect"); lcd.locate(0,1); lcd.printf("Undetect"); wait( 0.1 ); fclose( fp ); } int main(void) { Base::add_rpc_class<DigitalOut>(); lcd.cls(); lcd.locate(0,0); lcd.printf("Program init.. "); if (ethif.setup()) { error("Ethernet setup failed."); return 1; } led1=1; wait(1); led1=0; server.addHandler<SimpleHandler>("/hello"); server.addHandler<RPCHandler>("/rpc"); FSHandler::mount("/local", "/"); server.addHandler<FSHandler>("/"); server.bind(80); pin5.rise(&int_rise); // attach the address of the flip function to the rising edge pin5.fall(&int_fall); lcd.locate(0,0); lcd.printf("Now mode is "); int volt[2000]; int a[5]; int n=0, m=0, p=0, v=0, q=0; int v1, v2, v3; int min; check = 0; adc.setup(p19,1); volt_max=0; mled1 = 1; Base::add_rpc_class<DigitalOut>(); lcd.cls(); lcd.locate(0,0); lcd.printf("Program init.. "); if (ethif.setup()) { error("Ethernet setup failed."); return 1; } wait(1); server.addHandler<SimpleHandler>("/hello"); server.addHandler<RPCHandler>("/rpc"); FSHandler::mount("/local", "/"); server.addHandler<FSHandler>("/"); server.bind(80); while(1){ Net::poll(); } }