collapse

* Posts Recentes

O que é isto ? por SerraCabo
[12 de Abril de 2024, 14:20]


Amplificador - Rockboard HA 1 In-Ear por almamater
[11 de Abril de 2024, 20:46]


Emulador NES em ESP32 por dropes
[10 de Abril de 2024, 15:30]


Meu novo robô por josecarlos
[29 de Março de 2024, 18:30]


Bateria - Portátil por almamater
[25 de Março de 2024, 22:14]


Escolher Osciloscópio por jm_araujo
[06 de Fevereiro de 2024, 23:07]


TP4056 - Dúvida por dropes
[31 de Janeiro de 2024, 14:13]


Leitura de dados por Porta Serie por jm_araujo
[22 de Janeiro de 2024, 14:00]


Distancia Cabo por jm_araujo
[08 de Janeiro de 2024, 16:30]


Laser Engraver - Alguém tem? por almamater
[16 de Dezembro de 2023, 14:23]

Autor Tópico: Iniciante - juntar codigos  (Lida 22966 vezes)

0 Membros e 1 Visitante estão a ver este tópico.

Offline MRData

  • Mini Robot
  • *
  • Mensagens: 81
Re: Iniciante - juntar codigos
« Responder #45 em: 19 de Janeiro de 2015, 01:00 »
Boas,

Parece teres isto trocado
  //botao 2   
            if (((y>=90) && (y<=130)) && ((x>=150) && (x<=120)))

Devias ter  :
  //botao 2   
            if (((y>=90) && (y<=130)) && ((x>=120) && (x<=150)))

O X nao pode ser maior que 150 e menor que 120 ;)
"We are legion"

Offline MRData

  • Mini Robot
  • *
  • Mensagens: 81
Re: Iniciante - juntar codigos
« Responder #46 em: 19 de Janeiro de 2015, 18:46 »
Boas,

Ve se funciona o codigo, antes de testares no fim do teu codigo tens as linhas abaixo, onde diz "pin" tens de colocar o pin do RELE que queres ligar as 17h00 e o mesmo pin no codigo para desligar as 01h00 (esta a vermelho o que tens de substituir)

  getTime(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
  if ((hour == 17) && (minute == 00) && releState == false))
  {
    digitalWrite(pin,HIGH);
    releState = true;
  }
  if ((hour == 1) && (minute == 00) && (releState == true))
  {
    digitalWrite(pin,LOW);
    releState = false;
  }


Código: [Seleccione]
#define VT100_MODE  1
#define DS3231_I2C_ADDRESS 0x68
#include "Wire.h"
#include <UTFT.h>
#include <OneWire.h>
#include <UTouch.h>

// declaração das fontes que serão utilizadas
extern uint8_t SmallFont[];
extern uint8_t BigFont[];


// Convert normal decimal numbers to binary coded decimal
const int sensors = 1; //number of temperature sensors on the bus
int sensors_pin = 10; //the pin where the bus its connected to arduino
uint8_t sensors_address[sensors][8]; //here will store the sensors addresses for later use


const char *dayname[] = {"Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sabado"};
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

boolean releState = false;

UTFT myGLCD(ITDB32S,38,39,40,41);
UTouch  myTouch(6,5,4,3,2); // pinagem do touch

int rele2 = 12; //rele pin 12

OneWire  sensor_bus(sensors_pin);

float get_temperature (uint8_t *address);


byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}
void setup()
{
  Wire.begin();
  Serial.begin(9600);
  //setDS3231time(30,10,19,7,17,01,15);
  // set the initial time here:
  // DS3231 seconds, minutes, hours, day, date, month, year
  // setDS3231time(30,40,18,5,26,11,14);
  randomSeed(analogRead(0));

  pinMode(13, OUTPUT);            // pin relay do termostato


  myGLCD.InitLCD();
  myGLCD.clrScr(); //limpa o lcd quando carregado novo codigo
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 319, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);

  pinMode(rele2, OUTPUT); //rele pinv12

  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_HI);

  //definições de cores e imagem inicial
  myGLCD.clrScr();              //limpar ecra
  myGLCD.setColor(0, 255, 255); //cor das letras
  myGLCD.setBackColor(0, 0, 255);  //cor de fundo
  myGLCD.print("Return Pump", 10, 60);


  //resolução ecra 320x240
  // desenho do BOTAO ligar
  myGLCD.setColor(64, 64, 128);             //cor roxa R,G,B
  myGLCD.fillRoundRect(10, 90, 40, 130);  //função fazer retangulo com cantos redondos  (ponto inicio horizontal,ponto inicio vertical, 319, 239);
  myGLCD.setColor(255, 255, 255);           //cor branco
  myGLCD.drawRoundRect(10, 90, 40, 130);  //função fazer BORDAS retangulo com cantos redondos
  myGLCD.setBackColor(64, 64, 128);
  myGLCD.print("ON", 14, 100); // myGLCD.print("palavra a escrever", eixo X, eixo Y);
  myGLCD.setBackColor(0, 0, 0);

  // FAZER O BOTAO desligar
  myGLCD.setColor(64, 64, 128);             //cor roxa R,G,B
  myGLCD.fillRoundRect(45, 90, 75, 130); //função fazer retangulo com cantos redondos  (ponto inicio horizontal,ponto inicio vertical, 319, 239);
  myGLCD.setColor(255, 255, 255);           //cor branco
  myGLCD.drawRoundRect(45, 90, 75, 130); //função fazer BORDAS retangulo com cantos redondos
  myGLCD.setBackColor(64, 64, 128);
  myGLCD.print("OFF", 50, 100); // myGLCD.print("palavra a escrever", eixo X, eixo Y);
  myGLCD.setBackColor(0, 0, 0);

  //Definir o pin 13 ON no arranque

  digitalWrite(rele2, HIGH);


  int x,y,c=0;
  Serial.println("Starting to look for sensors...");
  for(x=0;x<sensors;x++){
    if(sensor_bus.search(sensors_address[x]))
      c++;
  }
  if(c > 0) {
    Serial.println("Found this sensors : ");
    for(x=0;x<sensors;x++) {
      Serial.print("\tSensor ");
      Serial.print(x+1);
      Serial.print(" at address : ");
      for(y=0;y<8;y++){
        Serial.print(sensors_address[x][y],HEX);
        Serial.print(" ");
      }
      Serial.println();
    }
  }
  else
    Serial.println("Didn't find any sensors");
}
void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)
{

  // Relogio
  // sets time and date data to DS3231

  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}

String displayTime()
{
  String buf = "";
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  Serial.print(hour, DEC);
  buf += hour;
  // convert the byte variable to a decimal number when displayed
  Serial.print(":");
  buf += ":";
  if (minute<10)
  {
    Serial.print("0");
    buf += "0";
  }
  Serial.print(minute, DEC);
  buf += minute;
  Serial.print(":");
  buf += ":";
  if (second<10)
  {
    Serial.print("0");
    buf += "0";
    buf += "0";
  }
  Serial.print(second, DEC);
  buf += second;
  Serial.print(" ");
  buf += " ";
  Serial.print(dayOfMonth, DEC);
  buf += dayOfMonth;
  Serial.print("/");
  buf += "/";
  Serial.print(month, DEC);
  buf += month;
  Serial.print("/");
  buf += "/";
  Serial.print(year, DEC);
  buf += year;
  Serial.print(" ");
  buf += " ";
  switch(dayOfWeek){
  case 1:
    Serial.println("Domingo");
    buf += "Domingo";
    break;
  case 2:
    Serial.println("Segunda");
    buf += "Segunda";
    break;
  case 3:
    Serial.println("Terça");
    buf += "Terça";
    break;
  case 4:
    Serial.println("Quarta");
    buf += "Quarta";
    break;
  case 5:
    Serial.println("Quinta");
    buf += "Quinta";
    break;
  case 6:
    Serial.println("Sexta");
    buf += "Sexta";
    break;
  case 7:
    Serial.println("Sabado");
    buf += "Sabado";
    break;
  } 

  for(int x=0;x<sensors;x++) {
    Serial.println(" ");
    buf += " ";


    Serial.print(" ");
    buf += " ";
    Serial.print(get_temperature(sensors_address[x]));
    buf += get_temperature(sensors_address[x]);

    Serial.println("C");
    buf += "C";
  }

  return buf;
}


float get_temperature(uint8_t *address) {
  byte data[12];
  int x;
  sensor_bus.reset();
  sensor_bus.select(address);
  sensor_bus.write(0x44,1);

  sensor_bus.reset();
  sensor_bus.select(address);
  sensor_bus.write(0xBE,1);
  for(x=0;x<9;x++){
    data[x] = sensor_bus.read();
  }


  unsigned short tr = data[0];
  tr = tr + data[1]*256;

  if(tr > 0xF000){
    tr = 0 - tr;
  }


  float temperature = (float)tr*(float)0.0625 ;

  //controlo temp
  if (temperature > 20){//temperatura selecionada
    digitalWrite(13, LOW);

  }
  else
    digitalWrite(13,HIGH);


  return temperature;




}

void getTime(byte &second, byte &minute, byte &hour, byte &dayOfWeek, byte &dayOfMonth, byte &month, byte &year)
{
  readDS3231time(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}



void loop()
{



  int buf[318];
  int x, x2;
  int y, y2;
  int r;


  //chama linha com info para o tft
  myGLCD.print(displayTime(), CENTER, 1) ;

  if (myTouch.dataAvailable())
  {
    myTouch.read();
    x=myTouch.getX();
    y=myTouch.getY();

    //botao 1
    if (((y>=90) && (y<=130)) && ((x>=10) && (x<=40)))
    {       
      digitalWrite(rele2, HIGH);

      myGLCD.setColor (255, 0, 0);
      myGLCD.drawRoundRect(10, 90, 40, 130);

    }
    else {
      myGLCD.setColor (255,255, 255);
      myGLCD.drawRoundRect(10, 90, 40, 130);
    }

    //botao 2
    if (((y>=90) && (y<=130)) && ((x>=45) && (x<=75)))
    {       
      digitalWrite(rele2, LOW);

      myGLCD.setColor (255, 0, 0);
      myGLCD.drawRoundRect(45, 90, 75, 130);

    }
    else {
      myGLCD.setColor (255, 255, 255);
      myGLCD.drawRoundRect(45, 90, 75, 130);
    }

  }
  //-----------------------------------------------------------------

  getTime(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
  if ((hour == 17) && (minute == 00) && releState == false))
  {
    digitalWrite(pin,HIGH);
    releState = true;
  }
  if ((hour == 1) && (minute == 00) && (releState == true))
  {
    digitalWrite(pin,LOW);
    releState = false;
  }
}
"We are legion"

Offline MRData

  • Mini Robot
  • *
  • Mensagens: 81
Re: Iniciante - juntar codigos
« Responder #47 em: 20 de Janeiro de 2015, 01:03 »
Tenta com este, tens de fazer a mesma alteração do PIN do rele.

Código: [Seleccione]
#define VT100_MODE  1
#define DS3231_I2C_ADDRESS 0x68
#include "Wire.h"
#include <UTFT.h>
#include <OneWire.h>
#include <UTouch.h>

// declaração das fontes que serão utilizadas
extern uint8_t SmallFont[];
extern uint8_t BigFont[];


// Convert normal decimal numbers to binary coded decimal
const int sensors = 1; //number of temperature sensors on the bus
int sensors_pin = 10; //the pin where the bus its connected to arduino
uint8_t sensors_address[sensors][8]; //here will store the sensors addresses for later use


const char *dayname[] = {"Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sabado"};
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

boolean releState = false;

UTFT myGLCD(ITDB32S,38,39,40,41);
UTouch  myTouch(6,5,4,3,2); // pinagem do touch

int rele2 = 12; //rele pin 12

OneWire  sensor_bus(sensors_pin);

float get_temperature (uint8_t *address);


byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}
void setup()
{
  Wire.begin();
  Serial.begin(9600);
  //setDS3231time(30,10,19,7,17,01,15);
  // set the initial time here:
  // DS3231 seconds, minutes, hours, day, date, month, year
  // setDS3231time(30,40,18,5,26,11,14);
  randomSeed(analogRead(0));

  pinMode(13, OUTPUT);            // pin relay do termostato


  myGLCD.InitLCD();
  myGLCD.clrScr(); //limpa o lcd quando carregado novo codigo
  myGLCD.setFont(SmallFont);
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 319, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);

  pinMode(rele2, OUTPUT); //rele pinv12

  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_HI);

  //definições de cores e imagem inicial
  myGLCD.clrScr();              //limpar ecra
  myGLCD.setColor(0, 255, 255); //cor das letras
  myGLCD.setBackColor(0, 0, 255);  //cor de fundo
  myGLCD.print("Return Pump", 10, 60);


  //resolução ecra 320x240
  // desenho do BOTAO ligar
  myGLCD.setColor(64, 64, 128);             //cor roxa R,G,B
  myGLCD.fillRoundRect(10, 90, 40, 130);  //função fazer retangulo com cantos redondos  (ponto inicio horizontal,ponto inicio vertical, 319, 239);
  myGLCD.setColor(255, 255, 255);           //cor branco
  myGLCD.drawRoundRect(10, 90, 40, 130);  //função fazer BORDAS retangulo com cantos redondos
  myGLCD.setBackColor(64, 64, 128);
  myGLCD.print("ON", 14, 100); // myGLCD.print("palavra a escrever", eixo X, eixo Y);
  myGLCD.setBackColor(0, 0, 0);

  // FAZER O BOTAO desligar
  myGLCD.setColor(64, 64, 128);             //cor roxa R,G,B
  myGLCD.fillRoundRect(45, 90, 75, 130); //função fazer retangulo com cantos redondos  (ponto inicio horizontal,ponto inicio vertical, 319, 239);
  myGLCD.setColor(255, 255, 255);           //cor branco
  myGLCD.drawRoundRect(45, 90, 75, 130); //função fazer BORDAS retangulo com cantos redondos
  myGLCD.setBackColor(64, 64, 128);
  myGLCD.print("OFF", 50, 100); // myGLCD.print("palavra a escrever", eixo X, eixo Y);
  myGLCD.setBackColor(0, 0, 0);

  //Definir o pin 13 ON no arranque

  digitalWrite(rele2, HIGH);


  int x,y,c=0;
  Serial.println("Starting to look for sensors...");
  for(x=0;x<sensors;x++){
    if(sensor_bus.search(sensors_address[x]))
      c++;
  }
  if(c > 0) {
    Serial.println("Found this sensors : ");
    for(x=0;x<sensors;x++) {
      Serial.print("\tSensor ");
      Serial.print(x+1);
      Serial.print(" at address : ");
      for(y=0;y<8;y++){
        Serial.print(sensors_address[x][y],HEX);
        Serial.print(" ");
      }
      Serial.println();
    }
  }
  else
    Serial.println("Didn't find any sensors");
}
void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)
{

  // Relogio
  // sets time and date data to DS3231

  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}

String displayTime()
{
  String buf = "";
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  Serial.print(hour, DEC);
  buf += hour;
  // convert the byte variable to a decimal number when displayed
  Serial.print(":");
  buf += ":";
  if (minute<10)
  {
    Serial.print("0");
    buf += "0";
  }
  Serial.print(minute, DEC);
  buf += minute;
  Serial.print(":");
  buf += ":";
  if (second<10)
  {
    Serial.print("0");
    buf += "0";
    buf += "0";
  }
  Serial.print(second, DEC);
  buf += second;
  Serial.print(" ");
  buf += " ";
  Serial.print(dayOfMonth, DEC);
  buf += dayOfMonth;
  Serial.print("/");
  buf += "/";
  Serial.print(month, DEC);
  buf += month;
  Serial.print("/");
  buf += "/";
  Serial.print(year, DEC);
  buf += year;
  Serial.print(" ");
  buf += " ";
  switch(dayOfWeek){
  case 1:
    Serial.println("Domingo");
    buf += "Domingo";
    break;
  case 2:
    Serial.println("Segunda");
    buf += "Segunda";
    break;
  case 3:
    Serial.println("Terça");
    buf += "Terça";
    break;
  case 4:
    Serial.println("Quarta");
    buf += "Quarta";
    break;
  case 5:
    Serial.println("Quinta");
    buf += "Quinta";
    break;
  case 6:
    Serial.println("Sexta");
    buf += "Sexta";
    break;
  case 7:
    Serial.println("Sabado");
    buf += "Sabado";
    break;
  } 

  for(int x=0;x<sensors;x++) {
    Serial.println(" ");
    buf += " ";


    Serial.print(" ");
    buf += " ";
    Serial.print(get_temperature(sensors_address[x]));
    buf += get_temperature(sensors_address[x]);

    Serial.println("C");
    buf += "C";
  }

  return buf;
}


float get_temperature(uint8_t *address) {
  byte data[12];
  int x;
  sensor_bus.reset();
  sensor_bus.select(address);
  sensor_bus.write(0x44,1);

  sensor_bus.reset();
  sensor_bus.select(address);
  sensor_bus.write(0xBE,1);
  for(x=0;x<9;x++){
    data[x] = sensor_bus.read();
  }


  unsigned short tr = data[0];
  tr = tr + data[1]*256;

  if(tr > 0xF000){
    tr = 0 - tr;
  }


  float temperature = (float)tr*(float)0.0625 ;

  //controlo temp
  if (temperature > 20){//temperatura selecionada
    digitalWrite(13, LOW);

  }
  else
    digitalWrite(13,HIGH);


  return temperature;




}

void getTime()
{
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,&year);
}



void loop()
{



  int buf[318];
  int x, x2;
  int y, y2;
  int r;


  //chama linha com info para o tft
  myGLCD.print(displayTime(), CENTER, 1) ;

  if (myTouch.dataAvailable())
  {
    myTouch.read();
    x=myTouch.getX();
    y=myTouch.getY();

    //botao 1
    if (((y>=90) && (y<=130)) && ((x>=10) && (x<=40)))
    {       
      digitalWrite(rele2, HIGH);

      myGLCD.setColor (255, 0, 0);
      myGLCD.drawRoundRect(10, 90, 40, 130);

    }
    else {
      myGLCD.setColor (255,255, 255);
      myGLCD.drawRoundRect(10, 90, 40, 130);
    }

    //botao 2
    if (((y>=90) && (y<=130)) && ((x>=45) && (x<=75)))
    {       
      digitalWrite(rele2, LOW);

      myGLCD.setColor (255, 0, 0);
      myGLCD.drawRoundRect(45, 90, 75, 130);

    }
    else {
      myGLCD.setColor (255, 255, 255);
      myGLCD.drawRoundRect(45, 90, 75, 130);
    }

  }
  //-----------------------------------------------------------------

  getTime();
  if ((hour == 17) && (minute == 00) && releState == false))
  {
    digitalWrite(pin,HIGH);
    releState = true;
  }
  if ((hour == 1) && (minute == 00) && (releState == true))
  {
    digitalWrite(pin,LOW);
    releState = false;
  }
}
"We are legion"

Offline jm_araujo

  • Mini Robot
  • *
  • Mensagens: 2.948
  • NERD!
Re: Iniciante - juntar codigos
« Responder #48 em: 20 de Janeiro de 2015, 10:50 »
 ::)
É só contar os parênteses....

Offline MRData

  • Mini Robot
  • *
  • Mensagens: 81
Re: Iniciante - juntar codigos
« Responder #49 em: 20 de Janeiro de 2015, 14:37 »
Sim é isso
"We are legion"

Offline senso

  • Global Moderator
  • Mini Robot
  • *****
  • Mensagens: 9.733
  • Helpdesk do sitio
Re: Iniciante - juntar codigos
« Responder #50 em: 23 de Janeiro de 2015, 20:49 »
Pesquisa por arduino menu system, maior parte será para lcd's 16x2 e afins.
Avr fanboy

Offline senso

  • Global Moderator
  • Mini Robot
  • *****
  • Mensagens: 9.733
  • Helpdesk do sitio
Re: Iniciante - juntar codigos
« Responder #51 em: 23 de Janeiro de 2015, 21:22 »
O conceito é o mesmo, é fazer uma máquina de estados, ideia muito por alto.
Estado 1 ( o ecra principal).
>Sub menu 1
>Sub menu 2
>Sub menu 3

SM = Sub Menu

Se clica em SM 1 usas um if e metes o texto relevante a esse SM, e por ai adiante, quando estás dentro do SM fazes os prints respectivos de cada sub menu, já tens ai o código base para saber se clicaste num botão, agarras nesse if que está ai anteriormente e crias uma função para verificar se uma zona(botão foi clicada).
Avr fanboy

StarRider

  • Visitante
Re: Iniciante - juntar codigos
« Responder #52 em: 25 de Janeiro de 2015, 15:38 »
Boas,

Para fazer o menu tive de começar de novo. Tenho um novo sketch com o menu e relógio, falta juntar o código para o sensor de temperatura. Já tentei juntar mas fica num constante loop.

Alguém pode dar uma vista de olhos nos códigos em anexo ?

Agradeço desde já o tempo despendido.

Esse source já vai nas 700 linhas de código (sem contar includes e libs), e cada vez que "enxertas"  mais
alguma funcionalidade copiada da net vens pedir que alguém meta o mesmo a funcionar, depois de um
tópico com 5 paginas de ajuda dá para perceber que ainda não aprendeste nada e que nem sequer tentas
resolver os problemas ... se calhar está na altura de parares e estudar e ler um pouco sobre programação
e arduino antes de avançar mais.

Uma coisa é ajudar numa ou outra situação, outra coisa é estares à espera que seja a boa vontade dos outros
a fazer o teu programa TODO, se calhar não estás à altura de tal projecto e devias optar por algo mais
simples ... pensa nisso.

Abraços,
PA

Offline KammutierSpule

  • Mini Robot
  • *
  • Mensagens: 1.482
Re: Iniciante - juntar codigos
« Responder #53 em: 25 de Janeiro de 2015, 16:52 »
barrma, varias coisas:

Se objectivos deste tipo de forums fosse partilhar conhecimentos, seria bom entao partilhar tambem os teus conhecimentos. E desde que aqui chegaste, o teu objectivo tem sido apenas "safar-te o teu projecto".
Mesmo que seja o caso em ca vir so pedir ajuda, quem ajuda, nao 'e em troca de nada, e' porque acredita em alguma coisa. Há pessoas que podem acreditar na satisfação das outras pessoas que ajuda, outras acreditam que ao ajudar estão a ajudar a outra pessoa a evoluir e a crescer no conhecimento. algo para o futuro da pessoa.. e que sao aquela motivação extra para crescer as suas capacidades e nao apenas "safar uma necessidade momentânea".

O StarRider ja te respondeu e esclareceu varias duvidas neste post e que tu agradeces-te. Se calhar ele esperava ver algum retorno nessa ajuda que as pessoas aqui tem dado e do tempo da vida delas que estao a gastar num projecto que nao e' o delas.


Relativamente ao teu projecto:
"é muito complexo" vs "nunca seria em tempo útil" vs "para uso pessoal" vs "o orçamento que me deram foi absurdo"
Se calhar agora começas a ver que nao sera' tao absurdo assim o orçamento pedido.
Existe um esquema (em anexo) que ilustra bem esta situação, agora so tens de saber em que ponto do esquema estas.

Neste teu projecto, a melhor pessoa para resolver os problemas és tu. Torna-se realmente absurdo que chegue a uma situação que por cada iteração (problema que tenhas) venhas aqui colocar o projecto todo e pedir as pessoas que deixem de fazer os seus projectos e dedicar-se a olhar para o teu.

Força ai e muito trabalho!

Offline senso

  • Global Moderator
  • Mini Robot
  • *****
  • Mensagens: 9.733
  • Helpdesk do sitio
Re: Iniciante - juntar codigos
« Responder #54 em: 25 de Janeiro de 2015, 16:59 »
É impressão minha ou falta aqui pelo menos um post no tópico?
Avr fanboy