Svend Kaffke / Mbed 2 deprecated 7SegmentDisplay

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003     //pins are sorted from upper left corner of the display to the lower right corner
00004     //the display has a common cathode
00005     //the display actally has 8 led's, the last one is a dot 
00006 DigitalOut led[8]={p18, p19, p17, p20, p16, p14, p15, p13};
00007 
00008 
00009     //each led that has to light up gets a 1, every other led gets a 0
00010     //its in order of the DigitalOut Pins above
00011 int number[11][8]={
00012                     {1,1,1,0,1,1,1,0},          //zero
00013                     {0,0,1,0,0,1,0,0},          //one
00014                     {1,0,1,1,1,0,1,0},          //two
00015                     {1,0,1,1,0,1,1,0},          //three
00016                     {0,1,1,1,0,1,0,0},          //four
00017                     {1,1,0,1,0,1,1,0},          //five
00018                     {1,1,0,1,1,1,1,0},          //six
00019                     {1,0,1,0,0,1,0,0},          //seven
00020                     {1,1,1,1,1,1,1,0},          //eight
00021                     {1,1,1,1,0,1,1,0},          //nine
00022                     {0,0,0,0,0,0,0,1}          //dot
00023                   };
00024 
00025 
00026 int main() {
00027     while (1) {
00028             //all led's off
00029         for(int i = 0; i<8;i++){led[i] = 0;}
00030         
00031             //display shows the number in this case 6
00032         for (int i=0; i<8; i++){led[i] = number[6][i];}         //the digit after "number" is displayed
00033 
00034             //before it gets tired
00035         wait(0.5);
00036     
00037     }
00038 }