Analog In

Dependencies:   mbed C12832_lcd

main.cpp

Committer:
corsa1600
Date:
2019-02-04
Revision:
0:c87395cfee48

File content as of revision 0:c87395cfee48:

#include "mbed.h"
//#include "C12832.h"
#include "C12832_lcd.h"

//C12832 lcd(p5, p7, p6, p8, p11);
C12832_LCD lcd ;

AnalogIn aiPoti1(p19);  // alternative p19 = P1_30,
AnalogIn aiPoti2(p20);  // alternative p20 = P1_31,

int main() 
{
    uint16_t wertP1;
    uint16_t wertP2;
    uint16_t x0, y0, x1, y1;
    
    lcd.cls();          // löscht lcd (clear screen)
    lcd.locate(0,0);    // x-position, y-position (x: 0-128; y: 0-32)
    //lcd.printf("Werte von Poti 1 und 2:");
    while(1) 
    {
         lcd.cls();
        wertP1 = aiPoti1.read_u16();
        wertP2 = aiPoti1.read_u16();
        x1=aiPoti1.read_u16();
        y1= aiPoti1.read_u16();
        // Cursor auf null setzen
        lcd.locate(0,0);
        
        lcd.printf("Spannung 1 = : %f V", aiPoti1.read()*3.3);
        printf("Spannung 1 = : %f V\n", aiPoti1.read()*3.3);
        lcd.fillrect (0,11, 127*aiPoti1.read(), 14, 1); // x0, y0, x1, y1,  letzte Stelle 1= black , 0 = white
        
        lcd.locate(0,15);
        lcd.printf("Spannung 2 = : %f V", aiPoti2.read()*3.3);
        lcd.fillrect (0, 25, 127*aiPoti2.read(), 28, 1);
        
        //lcd.printf("ADC-Wert 1= %x\n",wertP1);
        //printf("ADC-Wert 1= %x\n",wertP1);
        
        //lcd.printf("Spannung 2 = : %f V", aiPoti2.read()*3.3);
        
        printf("Spannung 2 = : %f V\n", aiPoti2.read()*3.3);
       
        wait_ms(100);
    }
}