Você está na página 1de 4

#define LCDWidth 240 //define screen width,height

#define LCDHeight 320


#define _Digole_Serial_UART_ //To tell compiler compile the special communication
only,

#include <DigoleSerial.h>
//--------UART setup
#if defined(_Digole_Serial_UART_)
DigoleSerialDisp mydisp(&Serial, 38400); //UART:Arduino UNO: Pin 1(TX)on arduino to
RX on module
#endif
//--------I2C setup
#if defined(_Digole_Serial_I2C_)
#include <Bounce.h>
#include <Wire.h>
DigoleSerialDisp mydisp(&Wire, '\x27'); //I2C:Arduino UNO: SDA (data line) is on
analog input pin 4, and SCL (clock line) is on analog input pin 5 on UNO and
Duemilanove
#endif
//--------SPI setup
#if defined(_Digole_Serial_SPI_)
DigoleSerialDisp mydisp(8, 9, 10, 11); //SPI:Pin 8: data, 9:clock, 10: SS, 11:SI.
you can assign 255 to SS, and hard ground SS pin on module
#endif

//define draw window


#define DW_X 5
#define DW_Y 8
#define DW_W (LCDWidth - 10)
#define DW_H (LCDHeight - 10)

const int Sensor1 = 2; // Sensor de impulso para contagem


const int BotaoMais1 = 3; // Boto incrementa contagem contagem
const int BotaoMenos1 = 4; // Boto decrementa contagem contagem
const int Reset1 = 5;

int Sensor=0;
int BotaoMais =0;
int BotaoMenos =0;
int Reset =0;

int ContadorTotal; // Varivel de integrao total


int Contador ; // Varivel de integrao parcial
int Aux ; //Auxiliar de contagem
int Temp1 ;
int Temp2 ;
int Temp3 ;

unsigned char i;
int c,d;

void setup() {

/****************************
* Zerando contadores
***************************/
Contador == 0;
ContadorTotal ==0;
Aux ==0;
Temp1 ==0;
Temp2 ==0;
Temp3 ==0;
/***************************
*
*/

// Inicializao de variaveis de entrada:


pinMode(Sensor1,INPUT);

pinMode(BotaoMais1, INPUT);

pinMode(BotaoMenos1, INPUT);

pinMode(Reset1, INPUT);

mydisp.begin(); //initiate serial port


mydisp.setBgColor(255); //set another back ground color
mydisp.clearScreen(); //CLear screen
mydisp.setColor(0);
for (i = 0; i < 4; i++)
{
mydisp.setRotation(i);
mydisp.drawStr(0, 0, "TOTALIZADOR"); //print string at 3,0 in draw window

}
delay(1000);
mydisp.setRotation(0); //change screen direction to 1, screen width and screen
height exchanged
mydisp.setDrawWindow(DW_X, DW_Y, DW_W, DW_H); //set a draw window left/top:5,8,
Height=LCDHeight-15, width=LCDWidth-10
mydisp.setColor(255);
unsigned char j=0;

for (i = 0; i < 10; i++)


{
mydisp.setBgColor(j);
mydisp.setColor(~j);

// mydisp.setBgColor(random(256)); //set another back ground color


mydisp.setRotation(i % 5);
mydisp.cleanDrawWindow();
mydisp.drawStr(0, 0, "TESTE"); //print string at 3,0 in draw window
mydisp.print(i);
delay(500);
j=~j;
}

for (i = 0; i < 49; i++)


{
mydisp.setRotation(i);
mydisp.drawStr(0, 0, "TOTAL DIA"); //print string at 3,0 in draw window
mydisp.drawStr(0, 1, "PARCIAL");
}
}

void loop() {

Sensor=digitalRead(Sensor1);
BotaoMais=digitalRead(BotaoMais1);
BotaoMenos=digitalRead(BotaoMenos1);
Reset=digitalRead(Reset1);

if (Sensor == HIGH) {
delay(100);
Aux = Aux + Sensor;
Contador = Contador + Sensor;
ContadorTotal = ContadorTotal + Sensor;

if (Aux > 49 ) {
Aux=0;
Contador=0;
mydisp.clearScreen();

/*Incrementa valor manualmente


*
*/
while (BotaoMais == HIGH){
Contador = Contador + 1;
ContadorTotal = ContadorTotal + 1;
delay(1000);
Temp2=Temp2+1;
if(Temp2>5){
Contador = Contador + 10;
ContadorTotal = ContadorTotal + 10;

Temp2 ==0;

/*Decrementa valor manualmente


*
*/
while (BotaoMenos == HIGH){
Contador = Contador - 1;
ContadorTotal = ContadorTotal - 1;
delay(1000);
Temp3=Temp3+1;
if(Temp3>5){
Contador = Contador - 10;
ContadorTotal = ContadorTotal - 10;

while (Reset == HIGH){


Temp1 = Temp1 + 1;
delay(1000);
if(Temp1>5){

Contador ==0;
ContadorTotal ==0;

mydisp.setRotation(Contador % 8);
mydisp.drawStr(0, 1, "PARCIAL=");
mydisp.print(Contador);

mydisp.setRotation(ContadorTotal % 8);
mydisp.drawStr(0, 0, "TOTAL DIA=");
mydisp.print(ContadorTotal);
delay(100);

Você também pode gostar