This is an incomplete project for an in-class activity with a seven segment display.
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /*! Lab2 00002 * Used to turn the FRDM-KL46Z into a voltmeter. 00003 * Modified from: https://developer.mbed.org/users/star297/code/FRDM-KL46Z-LCD-rtc-Demo/ 00004 * \author Matthew Shuman 00005 * 00006 * \date August 28th, 2016 00007 00008 * \bug No bugs yet 00009 00010 * @code 00011 * #include "mbed.h" 00012 * #include "SLCD.h" 00013 00014 * SLCD myLcd; 00015 * int myNumber=0; 00016 * int main() 00017 * { 00018 * while(1) { 00019 * myLcd.printf("00%2.0i",myNumber); 00020 * ++myNumber; 00021 * wait(.1); 00022 * }//end of while 00023 * }//end of main 00024 * @endcode 00025 */ 00026 00027 00028 #include "mbed.h" 00029 #include "SLCD.h" 00030 00031 SLCD slcd; //Setup the LCD on the FRDM-KL46Z. 00032 DigitalOut led1(LED1); //Setup the green LED. 00033 AnalogIn ReadVoltage(A0); //Setup the analog input. 00034 BusOut display(PTE31, PTE19, PTE18, PTE17, PTE16, PTE6, PTE3, PTE2); 00035 //This creates an array of ports with PTE2 is the MSB and PTE31 is the LSB. 00036 00037 main() 00038 { 00039 00040 //Add a pull up resistor to SW1. 00041 led1 = 0; //Turn on the green LED. 00042 slcd.DP1(1); //Turn on the decimal point 00043 00044 while(1) { 00045 led1=!led1; //Toggle the green LED 00046 for(int i=0; i<16 ; i++){ 00047 slcd.printf(" %i",i); //Use this line to read the analog input. 00048 switch(i){ 00049 case 0: display = 0x01;break; //also 0x01 //.abcedfg 00050 case 1: display = 0xCF;break; 00051 case 2: display = 0x92;break; 00052 case 3: display = 0x4F;break; 00053 case 4: display = 0x66;break; 00054 case 5: display = 0xA8;break; 00055 case 6: display = 0x40;break; 00056 case 7: display = 0x0F;break; 00057 case 8: display = 0x80;break; 00058 case 9: display = 0x77;break; 00059 }//end of switch 00060 wait(2); 00061 }//end of for 00062 }//end of while 00063 }//end of main
Generated on Sun Jul 24 2022 19:55:21 by 1.7.2