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.
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 BusOut onda(D2, D3, D4, D5); 00005 TextLCD display(PC_9, PC_8, PC_10, PC_12, PA_13, PA_14, TextLCD::LCD20x4); 00006 00007 00008 DigitalIn BA(D5); //Botão A 00009 DigitalIn BB(D6); //Botão B 00010 DigitalIn BC(D7); //Botão C 00011 00012 int i=0; 00013 int z=0; 00014 int x=0; 00015 int state=1; 00016 int temp; 00017 unsigned char Sen []={7,9,11,12,13,14,15,15,15,15,14,13,12,11,9,7,6,4,3,2,1,0,0,0,0,1,2,3,4,6}; 00018 00019 00020 int main(){ 00021 00022 display.cls(); 00023 display.printf("Tipos de Onda: \n"); 00024 display.printf("A - Onda Quadrada\n"); 00025 display.printf("B - Onda Triangular\n"); 00026 display.printf("C - Onda Senoidal\n"); 00027 00028 //Onda Quadrada 00029 if (BA<0.5) { 00030 display.cls(); 00031 display.printf("Frequencia:\n"); 00032 display.printf("A - 500 Hz\n"); 00033 display.printf("B - 300,12 Hz\n"); 00034 while (1) { //Escolhendo a Frequencia 00035 if (BA<0.5) { //500Hz 00036 temp=1000; 00037 break; 00038 } 00039 if (BB<0.5) { //300,12Hz 00040 temp=1666; 00041 break; 00042 } 00043 } 00044 display.cls(); 00045 display.printf("Gerando Quadrada\n"); 00046 display.printf("B - Parar\n"); 00047 while (BB>0.5) { //Apertar B para parar onda 00048 x=0; 00049 onda=x; 00050 printf("%i",x); 00051 wait_us(temp); 00052 x=15; 00053 onda=x; 00054 printf("%i",x); 00055 wait_us(temp); 00056 } 00057 } 00058 //Onda Triangular 00059 if (BB<0.5) { 00060 display.cls(); 00061 display.printf("Frequencia:\n"); 00062 display.printf("A - 505,05 Hz\n"); 00063 display.printf("B - 300,30 Hz\n"); 00064 while (1) { //Escolhendo a Frequencia 00065 if (BA<0.5) { //505,05Hz 00066 temp=66; 00067 break; 00068 } 00069 if (BB<0.5) { //300,30Hz 00070 temp=111; 00071 break; 00072 } 00073 } 00074 display.cls(); 00075 display.printf("Gerando Triangular\n"); 00076 display.printf("B - Parar\n"); 00077 while (BB>0.5) { //Apertar B para parar onda 00078 if (state==1) { 00079 onda=i; 00080 wait_us(temp); 00081 printf("%i\n",i); 00082 i=i+1; 00083 if (i==15) { 00084 state=2; 00085 } 00086 } 00087 if (state==2) { 00088 onda=i; 00089 wait_us(temp); 00090 printf("%i\n",i); 00091 i=i-1; 00092 if (i==0) { 00093 state=1; 00094 } 00095 } 00096 } 00097 } 00098 00099 00100 //Onda Senoidal 00101 if (BC<0.5) { 00102 display.cls(); 00103 display.printf("Frequencia:\n"); 00104 display.printf("A - 505,05 Hz\n"); 00105 display.printf("B - 300,30 Hz\n"); 00106 while (1) { //Escolhendo a Frequencia 00107 if (BA<0.5) { //505,05Hz 00108 temp=66; 00109 break; 00110 } 00111 if (BB<0.5) { //300,30Hz 00112 temp=111; 00113 break; 00114 } 00115 } 00116 display.cls(); 00117 display.printf("Gerando Senoidal\n"); 00118 display.printf("B - Parar\n"); 00119 while (BB>0.5) { //Apertar B para parar onda 00120 onda=Sen[z]; 00121 printf("%i",z); 00122 wait_us(temp); 00123 if (z==29) { 00124 z=0; 00125 } 00126 else{ 00127 z=z+1; 00128 } 00129 } 00130 } 00131 00132 }
Generated on Wed Jul 13 2022 21:07:53 by
1.7.2