Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Errors making a library on: July 09, 2014, 12:51:51 am
Now I'm trying this but I get this errors:
HomeAlarm\HomeAlarm.cpp.o: In function `HomeAlarm':
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.cpp:25: undefined reference to `Keypad::Keypad(char*, unsigned char*, unsigned char*, unsigned char, unsigned char)'
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.cpp:28: undefined reference to `LiquidCrystal_I2C::LiquidCrystal_I2C(unsigned char, unsigned char, unsigned char)'
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.cpp:29: undefined reference to `LiquidCrystal_I2C::init()'
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.cpp:30: undefined reference to `LiquidCrystal_I2C::backlight()'
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.cpp:31: undefined reference to `LiquidCrystal_I2C::home()'

My .CPP is
Code:
//Keypad
#include "../Keypad/Keypad.h"

//LCD I2C 16x2 //DFRobot.com
#include "../Wire/Wire.h"
#include "../LiquidCrystal_I2C/LiquidCrystal_I2C.h"


#include "HomeAlarm.h";

HomeAlarm::HomeAlarm(int spkPin){
Serial.begin(9600);
_spkPin = spkPin;
//Keypad
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte colPins[COLS] = {2,3,4,5};
byte rowPins[ROWS] = {6,7,8,9};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

//initialize the lcd
LiquidCrystal_I2C lcd(0x20,16,2);
lcd.init();
lcd.backlight();
lcd.home();
}
void HomeAlarm::ConfirmSound(){
tone(_spkPin, 400);
delay(500);
noTone(_spkPin);
tone(_spkPin, 500);
delay(500);
noTone(_spkPin);
}
void HomeAlarm::ErrSound(){
tone(_spkPin, 200);
delay(500);
noTone(_spkPin);
tone(_spkPin, 300);
delay(500);
noTone(_spkPin);
}
void HomeAlarm::keySound(){
tone(_spkPin, 750);
delay(100);
noTone(_spkPin);
}

My .h
Code:
#ifndef HOME_ALARM
#define HOME_ALARM

// Arduino versioning.
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class HomeAlarm{
public:
HomeAlarm(int spkPin);
void ConfirmSound();
void ErrSound();
void keySound();
private:
int _spkPin;
};
#endif
And the sketch
Code:
#include <HomeAlarm.h>

HomeAlarm alarm(10);//Buzzer pin

void setup(){
  alarm.ConfirmSound();
}
void loop(){
 
}
2  Using Arduino / Programming Questions / Re: Errors making a library on: July 08, 2014, 09:04:24 pm
Sorry I forget it
This is my new .CPP
Code:
//Keypad
#include "../Keypad/Keypad.h"
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte colPins[COLS] = {2,3,4,5};
byte rowPins[ROWS] = {6,7,8,9};

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );



//LCD I2C 16x2 //DFRobot.com
#include "../Wire/Wire.h"
#include "../LiquidCrystal_I2C/LiquidCrystal_I2C.h"
LiquidCrystal_I2C LCD(0x20,16,2);

#include "HomeAlarm.h";

HomeAlarm::HomeAlarm(int spkPin){
Serial.begin(9600);
_spkPin = spkPin;
//initialize the lcd
lcd.init();                      // initialize the lcd
lcd.backlight();
lcd.home();
}
void HomeAlarm::ConfirmSound(){
tone(_spkPin, 400);
delay(500);
noTone(_spkPin);
tone(_spkPin, 500);
delay(500);
noTone(_spkPin);
}
void HomeAlarm::ErrSound(){
tone(_spkPin, 200);
delay(500);
noTone(_spkPin);
tone(_spkPin, 300);
delay(500);
noTone(_spkPin);
}
void HomeAlarm::keySound(){
tone(_spkPin, 750);
delay(100);
noTone(_spkPin);
}

And this this my new .h
Code:
#ifndef HOME_ALARM
#define HOME_ALARM

// Arduino versioning.
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class HomeAlarm{
public:
HomeAlarm(int spkPin);
void ConfirmSound();
void ErrSound();
void keySound();
private:
int _spkPin;
};
#endif
This is the sketch
Code:
#include <HomeAlarm.h>

HomeAlarm alarm(10);//Buzzer pin

void setup(){
  alarm.ConfirmSound();
}
void loop(){
  
}
And the error log
HomeAlarm\HomeAlarm.cpp.o: In function `__static_initialization_and_destruction_0':
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.cpp:14: undefined reference to `Keypad::Keypad(char*, unsigned char*, unsigned char*, unsigned char, unsigned char)'
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.cpp:21: undefined reference to `LiquidCrystal_I2C::LiquidCrystal_I2C(unsigned char, unsigned char, unsigned char)'

P.D: If I use separate in the sketches don't have errors
3  Using Arduino / Programming Questions / Re: Errors making a library on: July 08, 2014, 08:36:16 pm
Hello, now I got some new problems. I hop that you can help me.
In my .CPP I'm trying  to call new instanses from other libraries. So this is my code:
Code:
//Keypad
#include "../Keypad/Keypad.h"
_ROWS = 4;
_COLS = 4;
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte colPins[COLS] = {2,3,4,5};
byte rowPins[ROWS] = {6,7,8,9};

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


//LCD I2C 16x2 //DFRobot.com
#include "../Wire/Wire.h"
#include "../LiquidCrystal_I2C/LiquidCrystal_I2C.h"
LiquidCrystal_I2C LCD(0x20,16,2);

#include "HomeAlarm.h";

HomeAlarm::HomeAlarm(int spkPin){
_spkPin = spkPin;
}
void HomeAlarm::ConfirmSound(){
tone(_spkPin, 400);
delay(500);
noTone(_spkPin);
tone(_spkPin, 500);
delay(500);
noTone(_spkPin);
}
void HomeAlarm::ErrSound(){
tone(_spkPin, 200);
delay(500);
noTone(_spkPin);
tone(_spkPin, 300);
delay(500);
noTone(_spkPin);
}
void HomeAlarm::keySound(){
tone(_spkPin, 750);
delay(100);
noTone(_spkPin);
}
This is my new .h
Code:
#ifndef HOME_ALARM
#define HOME_ALARM

// Arduino versioning.
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class HomeAlarm{
public:
HomeAlarm(int spkPin);
void ConfirmSound();
void ErrSound();
void keySound();
private:
int _spkPin;
int _LCD;
byte _ROWS;
byte _COLS;
};
#endif
P.D:  If I use only the sketch of lcd or Keypad I can use it.
4  Using Arduino / Programming Questions / Re: Errors making a library on: July 08, 2014, 07:38:35 am
A LOT OF THX
Code:
michinyon
and
Code:
luisilva
I got it for the explain of HOME_ALARM.
And
Code:
thxsteinie44
and
Code:
michinyon
I just trying to make an instance.
Code:
luisilva
a lot Thx.

Thx for the help, now I can continue coding.
5  Using Arduino / Programming Questions / Re: Errors making a library on: July 08, 2014, 07:05:33 am
Yes, it resolve the error thx, but why I need to write HOME_ALARM and not HomeAlarm.
And the other question is, why now I get this messages:
sketch_jul08a.ino: In function 'void setup()':
sketch_jul08a:6: error: request for member 'ErrSound' in 'alarma', which is of non-class type 'HomeAlarm ()()'

This is the sketch
Code:
#include <HomeAlarm.h>

HomeAlarm alarma();//Buzzer pin

void setup(){
  alarma.ErrSound();
}
void loop(){
  
}
I'm make changes in the .CPP and .H
This is my .H
Code:
#ifndef HOME_ALARM
#define HOME_ALARM

// Arduino versioning.
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class HomeAlarm{
public:
HomeAlarm();
void ErrSound();
private:
int _spkPin();
};
#endif
This is my .CPP
Code:
#include "HomeAlarm.h";

HomeAlarm::HomeAlarm(){
_spkPin = 13;
}
void HomeAlarm::ErrSound(){
tone(_spkPin, 200);
delay(500);
noTone(_spkPin);
tone(_spkPin, 300);
delay(500);
noTone(_spkPin);
}
This is my sketch
Code:
#include <HomeAlarm.h>

HomeAlarm alarm();//Buzzer pin

void setup(){
  alarm.ErrSound();
}
void loop(){
  
}
6  Using Arduino / Programming Questions / Re: Errors making a library on: July 08, 2014, 06:55:54 am
_spkPin is a private variable.
7  Using Arduino / Programming Questions / Errors making a library on: July 08, 2014, 06:43:37 am
I'm trying to write a library but when I use it get an errors.

This is my HomeAlarm.h
Code:
#ifndef HomeAlarm
#define HomeAlarm

// Arduino versioning.
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class HomeAlarm{
public:
HomeAlarm();
void ErrSound();
private:
int _spkPin;
};
#endif
This is HomeAlarm.cpp
Code:
#include "HomeAlarm.h";

HomeAlarm::HomeAlarm(){
_spkPin = 13;
}
void HomeAlarm::ErrSound(){
tone(speakerPin, 200);
delay(500);
noTone(speakerPin);
tone(speakerPin, 300);
delay(500);
noTone(speakerPin);
}
This is the calling
Code:
#include <HomeAlarm.h>

HomeAlarm alarma();//Buzzer pin

void setup(){
  alarma.ErrSound();
}
void loop(){
  
}
Those are the error that I get
In file included from sketch_jul08a.ino:1:
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.h:14: error: expected unqualified-id before ')' token
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.h:12: error: an anonymous struct cannot have function members
C:\Program Files (x86)\Arduino\libraries\HomeAlarm/HomeAlarm.h:18: error: abstract declarator '<anonymous class>' used as declaration
sketch_jul08a:3: error: expected constructor, destructor, or type conversion before ';' token
sketch_jul08a.ino: In function 'void setup()':
sketch_jul08a:6: error: 'alarma' was not declared in this scope


Thx for help me.
8  Using Arduino / Sensors / Ds18b20 long wire problem on: February 13, 2013, 04:10:19 pm
Hello, well I'm developing a system to get the temperature but I need put 20 sensors but the distance its too long, so I was trying with cat 5 ethernet cable, first I try with 3 sensor on each wire (using one wire) but I lost many data, so I try with 2 sensors in each wire, and I'm using 220ohm resistors but its change depending the long of the wire, is this ok or what can I do.
9  Using Arduino / Interfacing w/ Software on the Computer / Re: Why I can't connect on: February 13, 2013, 03:55:07 pm
hello I'm back again, the cpanel it's the control paranel from my webSite and I get this data:
Access your websitehttp://arduinosensor.hostzi.com
Access your website with www.http://www.arduinosensor.hostzi.com
Website IP address31.170.160.99
Server nameserver35.000webhost.com
and my code is this:
Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte gateway[] = { 192, 168, 1, 254 };
byte subnet[] = { 255, 255, 255, 0 };
IPAddress server( 31,170,160,99 );
int s[20];
EthernetClient client;

void setup(){
  Ethernet.begin(mac, gateway, subnet);
  delay(1000);
  Serial.begin(9600);
}
void loop(){
  for(int a=0;a<20;a++){
    s[a]=random(10, 15);
  }
  mysql_ins();
}
void mysql_ins(){
  if (client.connect(server, 80)) {
    client.print("GET /arduino/read.php?s1=");
    client.print(s[0]);
    for(int a=1;a<20;a++){
      client.print("&s");
      client.print(a+1);
      client.print("=");
      client.print(s[a]);
     
    }
    client.println(" HTTP/1.1");
    client.println("Host: localhost");
    client.println();
    Serial.println("ARDUINO: HTTP message sent");
    delay(3000);
    if(client.available()){
      Serial.println("ARDUINO: HTTP message received");
      Serial.println("ARDUINO: printing received headers and script response...\n");

      while(client.available()){
        char c = client.read();
        Serial.print(c);
      }
    }else{
      Serial.println("ARDUINO: no response received / no response received in time");
    }
    client.stop();
  }else{
    Serial.println("connection failure");
  }
}
10  Using Arduino / Interfacing w/ Software on the Computer / Re: Why I can't connect on: February 09, 2013, 06:26:50 pm
I cant see the server log... and how can I know the error?

I am trying to access by the ip 31.170.160.96/home/a9451348 but I can't. In the cpanel show me that ip to acces...
11  Using Arduino / Interfacing w/ Software on the Computer / Why I can't connect on: February 09, 2013, 04:37:52 pm
Hello, well I am new here, and have a question about why I can't connecto to 000webhost via ethernet shield this is my code.
Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte gateway[] = { 192, 168, 1, 254 };
byte subnet[] = { 255, 255, 255, 0 };
IPAddress server( 192,168,1,65 );
int s[20];
EthernetClient client;

void setup(){
  Ethernet.begin(mac, gateway, subnet);
  delay(1000);
  Serial.begin(9600);
}
void loop(){
  for(int a=0;a<20;a++){
    s[a]=random(10, 15);
  }
  mysql_ins();
}
void mysql_ins(){
  if (client.connect(server, 80)) {
    client.print("GET /arduino/read.php?s1=");
    client.print(s[0]);
    for(int a=1;a<20;a++){
      client.print("&s");
      client.print(a+1);
      client.print("=");
      client.print(s[a]);
     
    }
    client.println(" HTTP/1.1");
    client.println("Host: localhost");
    client.println();
    Serial.println("ARDUINO: HTTP message sent");
    delay(3000);
    if(client.available()){
      Serial.println("ARDUINO: HTTP message received");
      Serial.println("ARDUINO: printing received headers and script response...\n");

      while(client.available()){
        char c = client.read();
        Serial.print(c);
      }
    }else{
      Serial.println("ARDUINO: no response received / no response received in time");
    }
    client.stop();
  }else{
    Serial.println("connection failure");
  }
}
When I do it in my local computer I can acces but, I cant in 000webhost I set the server ip as it show me in the Cpanel.
Pages: [1]