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.
main.cpp
00001 #include "mbed.h" 00002 #include "Adb.h" 00003 #include <TextLCD.h> 00004 TextLCD lcd(p11, p12, p27, p28, p29, p30); 00005 Connection * connection; 00006 00007 Serial pc(USBTX, USBRX); 00008 PwmOut servo1(p26); 00009 PwmOut servo2(p25); 00010 DigitalIn sw1(p13); 00011 DigitalOut led(LED1); 00012 00013 void adbEventHandler(Connection * connection, adb_eventType event, uint16_t length, uint8_t * data) 00014 { 00015 if (event == ADB_CONNECTION_RECEIVE) 00016 { 00017 printf("[ADB RECV]:%d %d\r\n",data[0],data[1]); 00018 float val = ((float)data[0] * 5.5) + 1000.0; 00019 servo1.pulsewidth_us(val); 00020 val = ((float)data[1] * 5.5) + 1000.0; 00021 servo2.pulsewidth_us(val); 00022 } 00023 } 00024 00025 int main() 00026 { 00027 int now=0,old; 00028 unsigned short data = 0; 00029 00030 pc.baud(115200); 00031 servo1.period_us(20000); 00032 servo2.period_us(20000); 00033 sw1.mode(PullUp); 00034 00035 00036 // Initialise the ADB subsystem. 00037 ADB::init(); 00038 // Open an ADB stream to the phone's shell. Auto-reconnect 00039 connection = ADB::addConnection("tcp:4567", true, adbEventHandler); 00040 00041 while(1) 00042 { 00043 00044 ADB::poll(); 00045 00046 lcd.locate(0, 0); 00047 lcd.printf("MicroBridge Test"); 00048 00049 old = now; 00050 now = sw1; 00051 if((now == 1)&&(old==0)) 00052 { 00053 printf("down key\r\n"); 00054 connection->write(2, (unsigned char*)&data); 00055 lcd.locate(0, 1); 00056 lcd.printf("COUNT = %d",data); 00057 00058 data++; 00059 } 00060 led = sw1; 00061 } 00062 }
Generated on Tue Jul 12 2022 23:04:11 by
1.7.2