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 00003 // A class for flip()-ing a DigitalOut 00004 class Flipper { 00005 public: 00006 Flipper(PinName pin) : _pin(pin) { 00007 _pin = 0; 00008 } 00009 void flip() { 00010 _pin = !_pin; 00011 } 00012 private: 00013 DigitalOut _pin; 00014 }; 00015 00016 DigitalOut led1(LED1); 00017 DigitalOut led3(LED3); 00018 00019 Flipper f(LED2); 00020 Ticker t; 00021 00022 int main() { 00023 t.attach_us(&f, &Flipper::flip, 25); // the address of the object, member function, and interval 00024 // 25 us = 40kHz 00025 led3 = 1; 00026 00027 // spin in a main loop. flipper will interrupt it to call flip 00028 while(1) { 00029 led1 = !led1; 00030 wait(0.2); 00031 } 00032 }
Generated on Sun Aug 14 2022 03:24:53 by
1.7.2