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 Serial pc(USBTX, USBRX); 00003 // A class for flip()-ing a DigitalOut 00004 class Flipper { 00005 int ii; 00006 public: 00007 Flipper(PinName pin) : _pin(pin) { 00008 _pin = 0; 00009 ii = 0; 00010 } 00011 void flip() { 00012 ii++; 00013 if( ii > 4000 ) { 00014 _pin = !_pin; 00015 ii=0; 00016 } 00017 } 00018 private: 00019 00020 DigitalOut _pin; 00021 }; 00022 00023 DigitalOut led(LED1); 00024 DigitalOut led2(LED2); 00025 Flipper f(LED3); 00026 Ticker t; 00027 00028 int main() { 00029 t.attach_us(&f, &Flipper::flip, 25 ); // the address of the object, member function, and interval 00030 // 25 us = 40kHz 00031 //led3 = 1; 00032 00033 // spin in a main loop. flipper will interrupt it to call flip 00034 while(1) { 00035 led = !led; 00036 wait(0.5); 00037 } 00038 }
Generated on Wed Jul 27 2022 22:18:36 by
1.7.2