John Dickerson
/
AnalogOutIn
Sine wave out DAC and received in ADC and then sent out serial port
main.cpp@0:8f5eafbf1fa2, 2015-06-05 (annotated)
- Committer:
- JohnDickerson
- Date:
- Fri Jun 05 23:51:16 2015 +0000
- Revision:
- 0:8f5eafbf1fa2
Hello
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JohnDickerson | 0:8f5eafbf1fa2 | 1 | #include "mbed.h" |
JohnDickerson | 0:8f5eafbf1fa2 | 2 | |
JohnDickerson | 0:8f5eafbf1fa2 | 3 | AnalogOut aout(PTE30); |
JohnDickerson | 0:8f5eafbf1fa2 | 4 | AnalogIn ain(PTC2); |
JohnDickerson | 0:8f5eafbf1fa2 | 5 | Serial pc(USBTX,USBRX); |
JohnDickerson | 0:8f5eafbf1fa2 | 6 | DigitalOut myled(LED_GREEN); |
JohnDickerson | 0:8f5eafbf1fa2 | 7 | |
JohnDickerson | 0:8f5eafbf1fa2 | 8 | int main() { |
JohnDickerson | 0:8f5eafbf1fa2 | 9 | int i=0; |
JohnDickerson | 0:8f5eafbf1fa2 | 10 | float g[100]; |
JohnDickerson | 0:8f5eafbf1fa2 | 11 | myled=0; |
JohnDickerson | 0:8f5eafbf1fa2 | 12 | while(i<100) { |
JohnDickerson | 0:8f5eafbf1fa2 | 13 | aout = (1.0+(sin(2*3.14159*i/100.0)))/2.0; |
JohnDickerson | 0:8f5eafbf1fa2 | 14 | g[i]= ain; |
JohnDickerson | 0:8f5eafbf1fa2 | 15 | wait(.01); |
JohnDickerson | 0:8f5eafbf1fa2 | 16 | myled = !myled; |
JohnDickerson | 0:8f5eafbf1fa2 | 17 | i++; |
JohnDickerson | 0:8f5eafbf1fa2 | 18 | } |
JohnDickerson | 0:8f5eafbf1fa2 | 19 | i=0; |
JohnDickerson | 0:8f5eafbf1fa2 | 20 | while(i<100) { |
JohnDickerson | 0:8f5eafbf1fa2 | 21 | pc.printf("%f \n",g[i]); |
JohnDickerson | 0:8f5eafbf1fa2 | 22 | i++; |
JohnDickerson | 0:8f5eafbf1fa2 | 23 | } |
JohnDickerson | 0:8f5eafbf1fa2 | 24 | } |