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.
Diff: main.cpp
- Revision:
- 0:1f6f7de83adc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Mar 24 10:55:09 2014 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" + +using namespace std; + +BusOut segments(dp2, dp1, dp28, dp6, dp5, dp27, dp26); +BusOut digit(dp23, dp24, dp25); +DigitalOut decimal_point(dp4); +AnalogIn voltage(dp9); + + +int predefined_segments[10] = {0x01, 0x4f, 0x12, 0x06, 0x4c, 0x24, 0x20, 0x0f, 0x00, 0x04}; + +void display(float vtg) +{ + + int digits[3] = {(int)(vtg / 100) % 10, (int)(vtg / 10) % 10, (int)(vtg) % 10}; + for(int i = 1; i <= 4; i = i * 2) { + segments = predefined_segments[digits[i / 2]]; + digit = ~i; + decimal_point = (i == 1) ? 0 : 1; + wait_ms(1); + } +} + +int main() +{ + while(1) { + display(voltage * 3.3 * 100); + } +}