serial led
- include "mbed.h"
DigitalOut led1(LED2);
int main() {
while (1){
led1 = 1; wait(.2);
led1 = 0; wait(.2);
} }
- include "mbed.h"
Serial pc(p9, p10); tx, rx
int main() { pc.printf("Hello Worldo!\n"); } Hello World for printing RFID tag numbers
- include "mbed.h"
- include "ID12RFID.h"
ID12RFID rfid(p14); uart rx Serial LedMat(p9, p10); tx, rx
int main() { printf("Hello World\n"); while(1) { if(rfid.readable()) { LedMat. printf("RFID Tag number : %d\n", rfid.read()); }
- include "mbed.h"
AnalogOut signal(p18); float i;
int main() { while (1){ for( i = 0; i<6.28;i+=0.01) signal = sin(2*i) + .5; wait(0.01); } } } } #include "mbed.h"
Serial pc(USBTX, USBRX); tx, rx
int main() { pc.printf("Hello World!\n"); }
- include "mbed.h"
- include "EthernetNetIf.h"
- include "HTTPClient.h"
- include "NTPClient.h"
- include "HTTPServer.h"
- include "RPCFunction.h"
- define HOSTNAME "mbedSE"
EthernetNetIf eth(HOSTNAME); HTTPClient http; NTPClient ntp; HTTPServer svr;
DigitalOut led1(LED1, "led1"); DigitalOut led2(LED2, "led2"); DigitalOut led3(LED3, "led3"); DigitalOut led4(LED4, "led4");
void DoEcho(char* input, char* output); RPCFunction Echo(&DoEcho, "echo");
void DoEcho(char* input, char* output) { printf("%s\n", input); strcpy(output, input); }
int main() {
printf("\n\n/* Segundo Equipo NetServices library demonstration */\n"); printf("Try starting the program with the network disconnected and then connect after a few timeouts reported\n\n"); EthernetErr ethErr; int count = 0; do { printf("Setting up %d...\n", ++count); ethErr = eth.setup(); if (ethErr) printf("Timeout\n", ethErr); } while (ethErr != ETH_OK);
printf("Connected OK\n"); const char* hwAddr = eth.getHwAddr(); printf("HW address : %02x:%02x:%02x:%02x:%02x:%02x\n", hwAddr[0], hwAddr[1], hwAddr[2], hwAddr[3], hwAddr[4], hwAddr[5]);
IpAddr ethIp = eth.getIp(); printf("IP address : %d.%d.%d.%d\n", ethIp[0], ethIp[1], ethIp[2], ethIp[3]); printf("Check router DHCP table for name : %s\n", eth.getHostname());
printf("\nHTTPClient get...\n"); HTTPText txt; HTTPResult r = http.get("http://mbed.org/media/uploads/donatien/hello.txt", &txt); if (r==HTTP_OK) { printf("Result ok : %s\n", txt.gets()); } else { printf("Error %d\n", r); }
time_t ctTime; ctTime = time(NULL); printf("\nCurrent time is (UTC): %d %s\n", ctTime, ctime(&ctTime)); printf("NTP setTime...\n"); Host server(IpAddr(), 123, "pool.ntp.org"); printf("Result : %d\n", ntp.setTime(server));
ctTime = time(NULL); printf("\nTime is now (UTC): %d %s\n", ctTime, ctime(&ctTime));
printf("NTP setTime to a deliberately incorrect server...\n"); server.setName("www.google.com"); printf("Result : %d\n", ntp.setTime(server));
ctTime = time(NULL); printf("\nTime should still be correct (UTC): %d %s\n", ctTime, ctime(&ctTime));
char ip[16]; sprintf(ip, "%d.%d.%d.%d", ethIp[0], ethIp[1], ethIp[2], ethIp[3]);
- define PORT 80 svr.addHandler<RPCHandler>("/rpc"); svr.bind(PORT); printf("Server listening (port %d)\n", PORT); printf("- LED1 should flash\n"); printf("- type into browser to test url decode : %s/rpc/echo/run \"quoted string with <>\" or http://192.168.1.103/rpc/echo/run%%20%%22quoted%%20string%%20with%%20%%3C%%3E%%22\n", ip);
Timer tm; tm.start();
while (true) { Net::poll(); if (tm.read() > 0.5) { led1 = !led1; tm.start(); } } }
- include "mbed.h"
DigitalOut motor1(p19); DigitalOut motor2(p20); DigitalOut myled1(LED1); DigitalOut myled2(LED2);
int main() { while (1) { motor1=1; motor2=0; myled1=1; myled2=0; wait(1); motor1=0; motor2=1; myled1=0; myled2=1; wait(1); } }
- include "mbed.h"
DigitalOut motor1(p19); DigitalOut motor2(p20); DigitalOut myled1(LED1); DigitalOut myled2(LED2);
int main() { while (1) { motor1=1; motor2=0; myled1=1; myled2=0; wait(1); motor1=0; motor2=1; myled1=0; myled2=1; wait(1); } }
http://www.superdroidrobots.com/product_info/servo_modification.htm
- include "mbed.h"
DigitalOut motor0(p19); AnalogIn mypot(p20); PwmOut motor(p21);
int main() { motor0 = 0; motor.period_us(45); while (1) { motor = mypot.read(); } }
- include "mbed.h"
DigitalOut motor0(p19); AnalogIn mypot(p20); PwmOut motor(p21);
int main() { motor0 = 0; motor.period_us(45); while (1) { motor = mypot.read(); } }
- include "mbed.h"
DigitalOut trigger(p19); float i;\
int main() {
while (1){ send pulse trigger = 1; wait(0.00004); trigger = 1; }
}
Please log in to post comments.
