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.
Fork of mbed-os-example-mbed5-blinky by
main.cpp
00001 #include "mbed.h" 00002 #include "RotaryEncoder.h" 00003 00004 Serial pc(USBTX, USBRX); // tx, rx 00005 DigitalOut led1(LED1); 00006 00007 //RotaryEncoder(PinName pin1_name, PinName pin2_name, int min = 0, int max = 100, int val = 50); 00008 RotaryEncoder re1(D2, D3, 0, 8, 4); 00009 RotaryEncoder re2(D4, D5, -8, 0, -4); 00010 00011 // main() runs in its own thread in the OS 00012 int main() { 00013 pc.printf("Rotary Encoder Test\r\n"); 00014 00015 re1.setInterval(2000); 00016 re2.setInterval(2000); 00017 00018 pc.printf("re1: min=%d max=%d interval=%d\r\n", re1.getMin(), re1.getMax(), re1.getInterval()); 00019 pc.printf("re2: min=%d max=%d interval=%d\r\n", re2.getMin(), re2.getMax(), re2.getInterval()); 00020 00021 while (true) { 00022 pc.printf("%d\t%d\r\n", re1.getVal(), re2.getVal()); 00023 led1 = !led1; 00024 wait(0.1); 00025 } 00026 } 00027
Generated on Wed Jul 13 2022 04:46:48 by
1.7.2
