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.
Dependencies: mbed mbed-rtos ShiftOut
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 #include "ShiftOut.h" // Ollie Milton, https://os.mbed.com/users/ollie8/code/ShiftOut/ 00004 uint8_t segment_data[4] = {0xFF, 0xFF, 0xFF, 0xFF}; // A frissítendő szegmenskép 00005 /* Számjegyek (0 – 9) szegmensképe, negatív logikával */ 00006 const uint8_t SEGMENT_MAP[]= {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; 00007 /* Számjegy (1 - 4) kiválasztó jelek */ 00008 const uint8_t SEGMENT_SELECT[] = {0x01, 0x02, 0x04, 0x08}; 00009 00010 Thread thread; 00011 DigitalOut buzzer(D3); 00012 00013 void led2_thread() 00014 { 00015 ShiftOut display(D7, D8, D4); // clk=D7, data=D8, latch=D4) 00016 while (true) { 00017 for(int i = 0; i<4; i++) { 00018 display.write(segment_data[i]); 00019 display.write(SEGMENT_SELECT[i]); 00020 Thread::wait(2); 00021 } 00022 } 00023 } 00024 00025 int main() 00026 { 00027 int n =0; 00028 buzzer = true; 00029 thread.start(led2_thread); 00030 00031 while (true) { 00032 segment_data[0] = SEGMENT_MAP[(n/1000) %10]; 00033 segment_data[1] = SEGMENT_MAP[(n/100) % 10]; 00034 segment_data[2] = SEGMENT_MAP[(n/10) % 10]; 00035 segment_data[3] = SEGMENT_MAP[n % 10]; 00036 n = n+1; 00037 buzzer = (n%100) != 0; 00038 Thread::wait(250); 00039 } 00040 }
Generated on Mon Jul 25 2022 10:01:06 by
1.7.2