Repositório para o trabalho semestral (Projeto Estufa) de Microcontroladores.

Dependencies:   mbed

Committer:
plcpinho
Date:
Mon Jun 25 16:30:39 2018 +0000
Revision:
8:821e3ed311d0
Parent:
3:446af583421c
Projeto Finalizado

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RickBadKan 0:cdb895446e57 1 #include "mbed.h"
RickBadKan 0:cdb895446e57 2
RickBadKan 0:cdb895446e57 3 // Biblioteca para utilização do LCD Display
RickBadKan 0:cdb895446e57 4 #include "C12832.h"
RickBadKan 0:cdb895446e57 5
RickBadKan 0:cdb895446e57 6 AnalogIn sensor(p15);
RickBadKan 0:cdb895446e57 7
RickBadKan 3:446af583421c 8 // Visualização PWM
RickBadKan 3:446af583421c 9 PwmOut pwm(p21);
RickBadKan 0:cdb895446e57 10
RafaNegrao 1:4d014defc573 11 // Inicialização padrão para LCD
RickBadKan 0:cdb895446e57 12 C12832 lcd(p5, p7, p6, p8, p11);
RickBadKan 0:cdb895446e57 13
RickBadKan 0:cdb895446e57 14 int main(void)
RickBadKan 0:cdb895446e57 15 {
RickBadKan 0:cdb895446e57 16 lcd.cls();
RickBadKan 0:cdb895446e57 17
RickBadKan 0:cdb895446e57 18 // Codigo PWM
RickBadKan 3:446af583421c 19 pwm.period_ms(10);
RickBadKan 3:446af583421c 20 pwm.write(0.5f);
RickBadKan 0:cdb895446e57 21
RickBadKan 0:cdb895446e57 22 while (1) {
RickBadKan 0:cdb895446e57 23
RickBadKan 0:cdb895446e57 24
RickBadKan 0:cdb895446e57 25 // Print the % value and the absolute value from the sensor at p15
RickBadKan 0:cdb895446e57 26 lcd.locate(0,3);
RickBadKan 3:446af583421c 27 lcd.printf( "Percentage: %3.3f%% \n", (1-sensor.read()) * 100.0f );
RickBadKan 3:446af583421c 28 lcd.printf( "Absolute Value: %2.3f", 1-sensor.read() );
RickBadKan 3:446af583421c 29 wait(0.5f);
RickBadKan 0:cdb895446e57 30 lcd.cls();
RickBadKan 0:cdb895446e57 31 }
RickBadKan 0:cdb895446e57 32 }