Kian Sek Tee
/
sin_test
sine wave from A_out p18
Diff: main.cpp
- Revision:
- 0:4e035e5744a9
diff -r 000000000000 -r 4e035e5744a9 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 11 11:29:13 2010 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" +#include "TextLCD.h" +TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d0, d1, d2, d3 +AnalogOut signal(p18); + +float ff; +float pi; +float theta; + + +int main() { + pi = 3.142; + + while (1) { + theta=0; + for( int i=0; i < 63; i++ ) { + theta+=0.1; + ff = 0.5*sin(theta)+0.5; + signal=ff; + lcd.locate (0,0); + lcd.printf("%.2f", ff); + wait(0.001); + } + } +} \ No newline at end of file