**KL25Z** AnalogIn, TextLCD, USBDevice demo

Dependencies:   TextLCD USBDevice mbed

Fork of USBSerial_HelloWorld by Samuel Mokrani

Committer:
szjenter
Date:
Thu Aug 08 15:11:53 2013 +0000
Revision:
10:e48e63e91873
Parent:
9:d88699a0905a
mV Measuring; input:0-3.3V -> PTB4; output: LCD; USB Serial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
szjenter 10:e48e63e91873 1 /*mV_mero_01.cpp
szjenter 10:e48e63e91873 2 ********KL25Z********
szjenter 10:e48e63e91873 3
szjenter 10:e48e63e91873 4 input: 100K poti GND - P3V3 - A2(PTB2)
szjenter 10:e48e63e91873 5
szjenter 10:e48e63e91873 6 */
samux 7:5e693654d5b4 7 #include "mbed.h"
samux 7:5e693654d5b4 8 #include "USBSerial.h"
szjenter 10:e48e63e91873 9 #include "TextLCD.h"
szjenter 10:e48e63e91873 10
szjenter 10:e48e63e91873 11 TextLCD lcd(PTB8, PTB9, PTB10, PTB11, PTE2, PTE3); // rs, e, d4-d7 Aruino pin
szjenter 10:e48e63e91873 12
samux 7:5e693654d5b4 13 //Virtual serial port over USB
samux 7:5e693654d5b4 14 USBSerial serial;
szjenter 10:e48e63e91873 15 AnalogIn AnIn(PTB2); //A2
szjenter 10:e48e63e91873 16 DigitalOut K_led(LED1); //blue led
samux 7:5e693654d5b4 17 int main(void) {
szjenter 10:e48e63e91873 18 float volume=0; // displays init...
szjenter 10:e48e63e91873 19 K_led=0;
szjenter 10:e48e63e91873 20 lcd.cls();
szjenter 10:e48e63e91873 21 lcd.printf("*mV Measuring *\n"); // LCD
szjenter 10:e48e63e91873 22 lcd.printf(" --StART-- \n");
szjenter 10:e48e63e91873 23 serial.printf("*mV Measuring *\n"); //USB SERIEL (HiperTerminal)
szjenter 10:e48e63e91873 24 serial.printf(" --StART-- \n");
szjenter 10:e48e63e91873 25 wait(2);
szjenter 10:e48e63e91873 26 lcd.cls(); // TextLCD.h
samux 7:5e693654d5b4 27 while(1)
samux 7:5e693654d5b4 28 {
szjenter 10:e48e63e91873 29 volume=int(AnIn.read()*2880);
szjenter 10:e48e63e91873 30 lcd.locate(0,0);
szjenter 10:e48e63e91873 31 lcd.printf("Volume:%f",volume);
szjenter 10:e48e63e91873 32 lcd.locate(13,0);
szjenter 10:e48e63e91873 33 lcd.printf(" mV ");
szjenter 10:e48e63e91873 34 serial.printf("Volume:(%f) \r",volume);
szjenter 10:e48e63e91873 35 wait(0.25);
szjenter 10:e48e63e91873 36 K_led=!K_led;
samux 7:5e693654d5b4 37 }
samux 7:5e693654d5b4 38 }