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
Revision 1:eaa41cf396e0, committed 2015-12-10
- Comitter:
- tkrklec
- Date:
- Thu Dec 10 16:06:48 2015 +0000
- Parent:
- 0:8773e5f67fbc
- Commit message:
- Sinus_Tomislav Krklec
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8773e5f67fbc -r eaa41cf396e0 main.cpp --- a/main.cpp Thu Dec 03 18:00:47 2015 +0000 +++ b/main.cpp Thu Dec 10 16:06:48 2015 +0000 @@ -1,46 +1,20 @@ -//Reads input through the ADC, and transfers to PC terminal - #include "mbed.h" - Serial pc(USBTX, USBRX); - AnalogIn Ain(p20); - DigitalOut myled1(LED1); - DigitalOut myled2(LED2); - DigitalOut myled3(LED3); - DigitalOut myled4(LED4); - float x; - - int main() { - while (1) { - x=Ain; - wait (0.5); - if (x<=0.2){ - myled1=0; - myled2=0; - myled3=0; - myled4=0; +#include "mbed.h" + +#define INPUT_SCALAR (0.01f) //uklanjanje šumova signala + +AnalogIn Ain(p20); +AnalogOut Aout(p18); +float i; +float pi=3.14159; + +int main() +{ + while(1) { + for (i=0; i<2; i=i+0.005) { + Aout=0.5+0.5*sin(i*pi); + wait(Ain*INPUT_SCALAR); //regulacija vremena jedne periode preko potenciometra + } - else if (x>0.2&x<=0.4){ - myled1=1; - myled2=0; - myled3=0; - myled4=0; - } - else if (x>0.4&x<=0.6){ - myled1=1; - myled2=1; - myled3=0; - myled4=0; - } - else if (x>0.6&x<=0.8){ - myled1=1; - myled2=1; - myled3=1; - myled4=0; - } - else if (x>0.8&x<=1.0){ - myled1=1; - myled2=1; - myled3=1; - myled4=1; - } - } - } \ No newline at end of file + } +} + \ No newline at end of file