A LCD Program
Dependencies: TextLCD mbed Interruptpins
main.cpp
- Committer:
- wehner334
- Date:
- 2016-03-02
- Revision:
- 3:119ffed38b29
- Parent:
- 2:9693c1f2a4f2
File content as of revision 3:119ffed38b29:
#include "mbed.h" #include "TextLCD.h" #include "Interruptpins.h" TextLCD lcd(D2, D3, D4, D5, D6, D7, TextLCD::LCD8x2 ); Serial pc(SERIAL_TX, SERIAL_RX); DigitalOut myled(D10); AnalogIn aout(A3); InterruptIn mybuttonone(PA_0); InterruptIn mybuttontwo(PA_1); Timer Timerone; DigitalOut mynewled(A2); volatile long entprellZeit=250, alteZeitOne=0,alteZeitTwo=0,alteZeit=0; volatile int counterOne=0, counterTwo=0; void pressedone() {if((Timerone.read_ms()-alteZeitOne)>entprellZeit) {alteZeitOne=Timerone.read_ms(); lcd.locate(0,0); lcd.printf(" "); lcd.locate(0,0); counterOne++; if (pc.writeable()) { pc.printf("1,%i, %i \n",counterOne, alteZeitOne); //delay=buffer[movingVar]; } lcd.printf("Button 1\n"); } } void pressedtwo() {if((Timerone.read_ms()-alteZeitTwo)>entprellZeit) {alteZeitTwo=Timerone.read_ms(); lcd.locate(0,0); lcd.printf(" "); //lcd.printf("new"); lcd.locate(0,0); //delay=buffer[movingVar]; lcd.printf("Button 2\n"); counterTwo++; if (pc.writeable()) { pc.printf("2,%i,%i \n",counterTwo, alteZeitTwo); } } //wait(1); //lcd.cls(); /* movingVar++; if(movingVar==5) { movingVar=0; } */ } int main() { pc.baud(115200); mybuttonone.fall(&pressedone); mybuttonone.mode(PullUp); Timerone.start(); mybuttontwo.fall(&pressedtwo); mybuttontwo.mode(PullUp); lcd.printf("Hello World!\n"); wait(1); lcd.cls(); mynewled=true; while(1) { alteZeit=Timerone.read_ms(); if(alteZeit>1000) {Timerone.reset(); alteZeitOne=0; alteZeitTwo=0; alteZeit=0;} if(aout.read()<0.5f) { myled = !myled; } lcd.locate(0,0); lcd.printf(" "); //lcd.printf("new"); lcd.locate(0,1); lcd.printf("ana=%1.2f", aout.read() * 3.3f); wait(0.5); } }