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
main.cpp
- Committer:
- henriquer
- Date:
- 2020-05-29
- Revision:
- 0:cdadc6b7f2d1
- Child:
- 1:a0a660d54a0b
File content as of revision 0:cdadc6b7f2d1:
#include "mbed.h" BusOut Bus(D5,D6,D7); AnalogIn Ain (A0); Serial pc (USBTX,USBRX); InterruptIn button(USER_BUTTON); #define PI 3.141592f float valor ; float sen; int contador = 0; int j =0; void wave(void); void seno() { while(j!=100){ j++; for (int i=0; i <361; i++) { valor = 3.3 * Ain.read(); sen = 0.5*sin(i*(PI/180.0))+0.5; int n = (int) (sen*7); Bus = n; // pc.printf("\r\t%1.3f\n",valor); wait_ms(100); } } } void serra() { for(int i = 0; i<=15; i++) { Bus = i; valor = 3.3*Ain.read(); //pc.printf("\r\t%1.3f\n",valor); wait_ms(100); } } void square() { for(int i =0; i <=15; i=i++) { Bus = (i/10)*15; wait_ms(100); valor = 3.3*Ain.read(); // pc.printf("\r\t%1.3f\n",valor); } } void wave() { button==!button; contador = contador++; pc.printf("Contador: = %d\n\r",contador); switch(contador) { case 1: for (int i=1; i<10; i++) { seno(); wait_ms(20); } break; case 2: for (int i=10; i<20; i++) { serra(); wait_ms(20); } break; case 3: for (int i=20; i<30; i++) { square(); wait_ms(20); } break; case 4: for (int i=30; i<40; i++) { contador = 0; } break; } } int main() { button.fall(&wave); }