This program outputs the voltage to a DA converter and inputs it into AD converter and displays it to LCD. The voltage changes it to 3.3V by a 0.033 volts step from 0 volts and displays it every 0.5 seconds. DA port is p18. AD port is p20. It is necessary to short-circuit with a wire in p18 and p20 before executing a program. The voltage that output to a DA converter is displayed by the first line of the LCD. The voltage that read with AD converter is displayed by the second line of the LCD. See: http://blogs.yahoo.co.jp/jf1vrr_station/19783647.html (Japanese)

Dependencies:   TextLCD mbed

Committer:
jf1vrr
Date:
Sat Apr 16 11:17:07 2011 +0000
Revision:
0:de8d0a89c229
Rev.0.01A 2011/04/16

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jf1vrr 0:de8d0a89c229 1 /* This program outputs the voltage to a DA converter
jf1vrr 0:de8d0a89c229 2 and inputs it into AD converter and displays it to LCD.
jf1vrr 0:de8d0a89c229 3 The voltage changes it to 3.3V by a 0.033 volts step
jf1vrr 0:de8d0a89c229 4 from 0 volts and displays it every 0.5 seconds.
jf1vrr 0:de8d0a89c229 5 DA port is p18. AD port is p20. It is necessary to
jf1vrr 0:de8d0a89c229 6 short-circuit with a wire in p18 and p20 before
jf1vrr 0:de8d0a89c229 7 executing a program. The voltage that output to a
jf1vrr 0:de8d0a89c229 8 DA converter is displayed by the first line of the LCD.
jf1vrr 0:de8d0a89c229 9 The voltage that read with AD converter is displayed
jf1vrr 0:de8d0a89c229 10 by the second line of the LCD.
jf1vrr 0:de8d0a89c229 11 */
jf1vrr 0:de8d0a89c229 12 #include "mbed.h"
jf1vrr 0:de8d0a89c229 13 #include "TextLCD.h"
jf1vrr 0:de8d0a89c229 14
jf1vrr 0:de8d0a89c229 15 TextLCD lcd(p24, p26, p27, p28, p29, p30);
jf1vrr 0:de8d0a89c229 16
jf1vrr 0:de8d0a89c229 17 AnalogOut daval(p18);
jf1vrr 0:de8d0a89c229 18 AnalogIn adval(p20);
jf1vrr 0:de8d0a89c229 19
jf1vrr 0:de8d0a89c229 20 int main() {
jf1vrr 0:de8d0a89c229 21 //lcd.printf("Analog out test\n");
jf1vrr 0:de8d0a89c229 22 while(1) {
jf1vrr 0:de8d0a89c229 23 for(float i=0.0; i<1.0; i+=0.01) {
jf1vrr 0:de8d0a89c229 24 lcd.locate(0,0);
jf1vrr 0:de8d0a89c229 25 lcd.printf("D/A out %0.2fV",i*3.3);
jf1vrr 0:de8d0a89c229 26 daval = i;
jf1vrr 0:de8d0a89c229 27 wait(0.05);
jf1vrr 0:de8d0a89c229 28 lcd.locate(0,1);
jf1vrr 0:de8d0a89c229 29 lcd.printf("A/D in %0.2fV",adval.read()*3.3);
jf1vrr 0:de8d0a89c229 30 wait(0.5);
jf1vrr 0:de8d0a89c229 31 }
jf1vrr 0:de8d0a89c229 32 }
jf1vrr 0:de8d0a89c229 33 }