Escolar Documentos
Profissional Documentos
Cultura Documentos
#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 <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
#include <Bounce.h>
#define AumentoMan 3
#define DiminuirMan 4
#define Sensor 5
#define Reset 6
#define DEBOUNCE_TIME 5 // Tempo em 5 ms
Bounce aumentar = Bounce(AumentoMan,DEBOUNCE_TIME);
Bounce diminuir = Bounce(DiminuirMan,DEBOUNCE_TIME);
Bounce sensor = Bounce(Sensor,DEBOUNCE_TIME);
Bounce reset = Bounce(Reset,DEBOUNCE_TIME);
int ContadorTotal; // Varivel de integrao total
int Contador ; // Varivel de integrao parcial
int Aux ;
const int AlarmeSonoro = 13; //Pino 13 rel para acionamento de sirene
unsigned char i;
int c,d;
void setup() {
/****************************
* Zerando contadores
***************************/
pinMode(AlarmeSonoro, OUTPUT);
pinMode(AumentoMan, INPUT_PULLUP);
pinMode(DiminuirMan, INPUT_PULLUP);
pinMode(Sensor, INPUT_PULLUP);
pinMode(Reset, INPUT_PULLUP);
Serial.begin(9600);
Serial.println("Producao");
Contador == 0;
ContadorTotal ==0;
Aux ==0;
Sensor==0;
/***************************
*
*/
}
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;
void loop() {
if(sensor.update()){
if(sensor.read() ==LOW)
sensor.rebounce(300);
Aux = Aux + (Sensor-4);
Contador = Contador +(Sensor-4);
ContadorTotal = ContadorTotal +(Sensor-4);
// Serial.print("Contagem Sensor: ");
// Serial.println(Contador);
// Serial.print("Contagem Total: ");
// Serial.println(ContadorTotal);
delay(1000);
if (Aux > 49 ) {
Aux=0;
Contador=0;
mydisp.clearScreen(); //Limpa Tela
/*
* Incremento manual da contagem
*/
if(aumentar.update()){
if(aumentar.read() ==LOW){
aumentar.rebounce(300);
if(Contador<49){
Contador ++;
ContadorTotal++;
Aux++;
// Serial.print("Aumento Contagem: ");
// Serial.println(Contador);
mydisp.clearScreen(); //Limpa Tela
}
}
}
/*
* Decremento manual da contagem
*/
if(diminuir.update()){
if(diminuir.read() ==LOW){
diminuir.rebounce(300);
if(Contador>1){
Contador --;
ContadorTotal--;
Aux --;
}
}
}
/*
* Reset dos contadores
*/
if(reset.update()){
if(reset.read() ==LOW){
reset.rebounce(1000);
Contador=0 ;
ContadorTotal=0;
// Serial.print("Contagem Sensor: ");
// Serial.println(Contador);
// Serial.print("Contagem Total: ");
// Serial.println(ContadorTotal);
mydisp.setRotation(ContadorTotal % 8);
mydisp.drawStr(0, 0, "RESET=");
mydisp.print(ContadorTotal);
delay(2000);
}
}
}