Matija Pozojevic

Dependencies:   TextLCD mbed

main.cpp

Committer:
mpozojevi
Date:
2015-06-19
Revision:
0:b69a322d02df

File content as of revision 0:b69a322d02df:

#include "mbed.h"
#include "TextLCD.h"
#include "string"
#include  "stdlib.h"
DigitalIn next(p7); //tipkalo NEXT
DigitalIn back(p8); //tipkalo back
DigitalOut izlaz(LED2); //Pauza
DigitalOut izlaz2(LED1); //Ekspozicija
AnalogIn potenciometar(p15);
float vrijednost = 0;
float expo = 0;
std::string expoS;

int pauza = 0;
int brexp = 0;
int a = 0;
TextLCD lcd(p19, p20, p21, p22, p23, p24); //rs,e,d0,d1,d2,d3
// TextLCD lcd(p19, p20, p21, p22, p23, p24,TextLCD::LCD8x2);

Serial pc(USBTX, USBRX);

int main()
{
    lcd.cls();


    while (1) {
        expo=potenciometar;
        lcd.locate(0,0);
        lcd.printf("Expo: ");
        lcd.locate(0,1);


        if (potenciometar < 0.2) {
            lcd.printf("1/20s");
            expo = 1/20;
        }
        if (potenciometar > 0.2 && potenciometar <=0.4) {
            lcd.printf("1/5 s");
            expo = 1/5;
        }
        if (potenciometar > 0.4 && potenciometar <=0.6) {
            lcd.printf("1/2 s");
            expo = 1/2;
        }
        if (potenciometar > 0.6 && potenciometar <=0.8) {
            lcd.printf("1   s");
            expo = 1;
        }
        if (potenciometar > 0.8 && potenciometar <=1.0) {
            lcd.printf("2   s");
            expo = 2;
        }

        wait (0.2);

        if (next==1) {

            while (1) {

                lcd.cls();
                lcd.printf("Pauza: ");
                pauza = potenciometar * 10;
                lcd.locate(0,1);
                lcd.printf("%i ", pauza);
                wait (0.2);
                if (back ==1) break;
                if (next==1) {

                    lcd.cls();
                    lcd.printf("Broj exp");
                    while (1) {

                        brexp = potenciometar * 10 +1;
                        lcd.locate(0,1);
                        lcd.printf(": %i ", brexp);
                        wait (0.2);

                        {
                            if (back ==1) break;
                            if (next==1) {

                                while (1) {

                                    do {
                                        a++;
                                        lcd.cls();
                                        lcd.locate(0,0);
                                        lcd.printf("Exp br: ");
                                        lcd.locate(0,1);
                                        lcd.printf("  %i", a);
                                        izlaz = 1;
                                        izlaz2 = 0;
                                        wait(expo);


                                        lcd.cls();
                                        lcd.locate(0,0);
                                        lcd.printf("Pauza br");
                                        lcd.locate(0,1);
                                        lcd.printf(": %i", a);
                                        izlaz = 0;
                                        izlaz2 = 1;
                                        wait (pauza);
                                    } while (a<brexp);

                                    lcd.cls();
                                    lcd.locate(0,0);
                                    lcd.printf("Gotovo");
                                    lcd.locate(0,1);
                                    lcd.printf("!!!!");
                                    exit(1);

                                }
                            }
                        }

                    }
                }
            }
        }
    }
}