Show Posts
Pages: 1 [2] 3 4 ... 23
16  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 06:31:20 pm
Code:
  if (LedState == HIGH)
  {
    LedState==LOW;

Time to start reading a basic C tutorial. Don't just thrash around posting whatever comes into your head.

Do some simple programs first. Get the hang of it. Trying to do Twitter in your first code is ridiculous.

nick its not my first code, but i did have pratice for long so im kind stck here, that if sentence was proposed by someone on tne debounce thing, so im not used to that i ust leave it that way.....
17  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 04:32:29 pm
ok that really helps me out,

now there its only one error

Code:
SimplePost.ino: In function 'void loop()':
SimplePost:84: error: invalid conversion from 'char' to 'const char*'
SimplePost:84: error: initializing argument 1 of 'bool Twitter::post(const char*)'
18  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 04:27:43 pm
sorry for that i dindt save the last code mods...

Code:
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>

// The includion of EthernetDNS is not needed in Arduino IDE 1.0 or later.
// Please uncomment below in Arduino IDE 0022 or earlier.
//#include <EthernetDNS.h>
int count=0;
int LedState=LOW ;
// Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = { 192, 168, 2, 250 };

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("YOUR-TOKEN-HERE");

// Message to post
char* msg;
char str1[]="post one";
char str2[]="post two";
char str3[]="post three";
char str4[]="post four";
char str5[]="post five";
char str6[]="post six";

void setup()
{
  digitalWrite(2, HIGH);
  attachInterrupt(0, alarm, RISING);
  
  delay(1000);
  Ethernet.begin(mac);
  // or you can use DHCP for autoomatic IP address configuration.
  // Ethernet.begin(mac);
  Serial.begin(9600);
  
 
}
void loop()

 {
  if (LedState == HIGH)
  {
    LedState==LOW;
    
    switch (count)
    { case 1:
    msg =& str1;
    count++;
    break;
    
    case 2:
    msg =& str2;
    count++;
    break;
    
    case 3:
    msg =& str3;
    count++;
    break;
    
    
    case 4:
    msg =& str4;
    count++;
    break;
    
    case 5:
    msg =& str5;
    count++;
    break;
    case 6:
    msg =& str6;
    count=0;
    break;
    }
     }
    
    
    
   Serial.println("connecting ...");
  if (twitter.post(*msg)) {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait(&Serial);
    if (status == 200) {
      Serial.println("OK.");
    } else {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } else {
    Serial.println("connection failed.");
  }

  
  

}

 void alarm()
 {
  LedState = HIGH;
  
 }

this is still bad assigned pointer, but i dont know how to assing a char pointer to a char variable, sorry for that
19  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 04:11:39 pm
this is the code so

Code:
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>

// The includion of EthernetDNS is not needed in Arduino IDE 1.0 or later.
// Please uncomment below in Arduino IDE 0022 or earlier.
//#include <EthernetDNS.h>

int LedState=LOW ;
// Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = { 192, 168, 2, 250 };

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("YOUR-TOKEN-HERE");

// Message to post
char* msg[26];
char str1[]="post one";
char str2[]="post two";
char str3[]="post three";
char str4[]="post four";
char str5[]="post five";
char str6[]="post six";

void setup()
{
  digitalWrite(2, HIGH);
  attachInterrupt(0, alarm, RISING);
 
  delay(1000);
  Ethernet.begin(mac);
  // or you can use DHCP for autoomatic IP address configuration.
  // Ethernet.begin(mac);
  Serial.begin(9600);
 
 

void loop()

 
  if (ledState == HIGH)
  {
    LedState==LOW;
   
    Swtich (count)
    { case 1:
    msg =& str1;
    count++;
    break
   
    case 2:
    msg =& str2;
    count++;
    break
   
    case 3:
    msg =& str3;
    count++;
    break
   
   
    case 4:
    msg =& str4;
    count++;
    break
   
    case 5:
    msg =& str5;
    count++;
    break
    case 6:
    msg =& str6;
    count=0;
    break;
    }
     }
   
   
   
   Serial.println("connecting ...");
  if (twitter.post(*msg)) {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait(&Serial);
    if (status == 200) {
      Serial.println("OK.");
    } else {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } else {
    Serial.println("connection failed.");
  }

 
 



 void alarm()
 {
  ledState = HIGH;
   
 }
20  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 04:05:20 pm
Code:
*msg =& str1;

The type of "*msg" is "char", but you're trying to assign an address to it.
That's why the compiler is upset.

i understand that but, how can assing the variable and not the address??
21  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 02:52:13 pm
Why ask me? What does the compiler say?

cos you maybe know where im mistaking but you want me to learn not that someone writes my code...

Code:
SimplePost.ino: In function 'void loop()':
SimplePost:50: error: cannot convert 'char (*)[9]' to 'char*' in assignment
SimplePost:55: error: cannot convert 'char (*)[9]' to 'char*' in assignment
SimplePost:60: error: cannot convert 'char (*)[11]' to 'char*' in assignment
SimplePost:66: error: cannot convert 'char (*)[10]' to 'char*' in assignment
SimplePost:71: error: cannot convert 'char (*)[10]' to 'char*' in assignment
SimplePost:75: error: cannot convert 'char (*)[9]' to 'char*' in assignment
22  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 02:48:42 pm
you mean something like this???

Code:
char* msg;
23  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 02:44:31 pm
Quote
yes now the main problem its the pointer
Don't hold back - feel free to share.

this are tyhe errors the compilers shows


Code:
SimplePost.ino: In function 'void loop()':
SimplePost:50: error: invalid type argument of 'unary *'
SimplePost:55: error: invalid conversion from 'char (*)[9]' to 'char'
SimplePost:60: error: invalid conversion from 'char (*)[11]' to 'char'
SimplePost:66: error: invalid conversion from 'char (*)[10]' to 'char'
SimplePost:71: error: invalid conversion from 'char (*)[10]' to 'char'
SimplePost:75: error: invalid conversion from 'char (*)[9]' to 'char'
SimplePost:84: error: invalid conversion from 'char' to 'const char*'
SimplePost:84: error: initializing argument 1 of 'bool Twitter::post(const char*)'
24  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 02:41:48 pm
yes now the main problem its the pointer


Code:
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>

// The includion of EthernetDNS is not needed in Arduino IDE 1.0 or later.
// Please uncomment below in Arduino IDE 0022 or earlier.
//#include <EthernetDNS.h>
int count;
int LedState=LOW ;
// Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = { 192, 168, 2, 250 };

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("YOUR-TOKEN-HERE");

// Message to post
char msg;
char str1[]="post one";
char str2[]="post two";
char str3[]="post three";
char str4[]="post four";
char str5[]="post five";
char str6[]="post six";

void setup()
{
  digitalWrite(2, HIGH);
  attachInterrupt(0, alarm, RISING);
 
  delay(1000);
  Ethernet.begin(mac);
  // or you can use DHCP for autoomatic IP address configuration.
  // Ethernet.begin(mac);
  Serial.begin(9600);
 
 }

void loop()

 {
  if (LedState == HIGH)
  {
    LedState==LOW;
   
    switch (count)
    { case 1:
    *msg =& str1;
    count++;
    break;
   
    case 2:
    msg =& str2;
    count++;
    break;
   
    case 3:
    msg =& str3;
    count++;
    break;
   
   
    case 4:
    msg =& str4;
    count++;
    break;
   
    case 5:
    msg =& str5;
    count++;
    break;
    case 6:
    msg =& str6;
    count=0;
    break;
    }
     }
   
   
   
   Serial.println("connecting ...");
  if (twitter.post(msg)) {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait(&Serial);
    if (status == 200) {
      Serial.println("OK.");
    } else {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } else {
    Serial.println("connection failed.");
  }

 
  }



 void alarm()
 {
  LedState = HIGH;
   
 }
25  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 02:31:50 pm
the void loop need to have an open brace.....

now that problem has clear, and the main problem now its that im using and incorrect call of the pointers
26  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 02:24:04 pm
y see that mistake sorry if i didnt see it.....

and if i just call msg as an char pointer and not an array????

like
Code:
char *msg;


still the compiler says im wrong in the if funtion

Code:
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>

// The includion of EthernetDNS is not needed in Arduino IDE 1.0 or later.
// Please uncomment below in Arduino IDE 0022 or earlier.
//#include <EthernetDNS.h>

int LedState=LOW ;
// Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = { 192, 168, 2, 250 };

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("YOUR-TOKEN-HERE");

// Message to post
char* msg[26];
char str1[]="post one";
char str2[]="post two";
char str3[]="post three";
char str4[]="post four";
char str5[]="post five";
char str6[]="post six";

void setup()
{
  digitalWrite(2, HIGH);
  attachInterrupt(0, alarm, RISING);
 
  delay(1000);
  Ethernet.begin(mac);
  // or you can use DHCP for autoomatic IP address configuration.
  // Ethernet.begin(mac);
  Serial.begin(9600);
 
  }

void loop()

 
  if (ledState == HIGH)
  {
    LedState==LOW;
   
    Swtich (count)
    { case 1:
    msg =& str1;
    count++;
    break
   
    case 2:
    msg =& str2;
    count++;
    break
   
    case 3:
    msg =& str3;
    count++;
    break
   
   
    case 4:
    msg =& str4;
    count++;
    break
   
    case 5:
    msg =& str5;
    count++;
    break
    case 6:
    msg =& str6;
    count=0;
    break;
    }
     }
   
   
   
   Serial.println("connecting ...");
  if (twitter.post(*msg)) {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait(&Serial);
    if (status == 200) {
      Serial.println("OK.");
    } else {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } else {
    Serial.println("connection failed.");
  }

 
 



 void alarm()
 {
  ledState = HIGH;
   
 }


27  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 01:47:54 pm
ok, i have made some crrections but, still IDE says expected initializer before 'if'

Code:
[quote]
  [#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>

// The includion of EthernetDNS is not needed in Arduino IDE 1.0 or later.
// Please uncomment below in Arduino IDE 0022 or earlier.
//#include <EthernetDNS.h>

int LedState=LOW ;
// Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = { 192, 168, 2, 250 };

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("YOUR-TOKEN-HERE");

// Message to post
char* msg[26];
char str1[]="post one";
char str2[]="post two";
char str3[]="post three";
char str4[]="post four";
char str5[]="post five";
char str6[]="post six";

void setup()
{
  digitalWrite(2, HIGH);
  attachInterrupt(0, alarm, RISING);
 
  delay(1000);
  Ethernet.begin(mac);
  // or you can use DHCP for autoomatic IP address configuration.
  // Ethernet.begin(mac);
  Serial.begin(9600);
 
 

void loop()

 
  if (ledState == HIGH)
  {
    LedState==LOW;
   
    Swtich (count)
    { case 1:
    msg =& str1;
    count++;
    break
   
    case 2:
    msg =& str2;
    count++;
    break
   
    case 3:
    msg =& str3;
    count++;
    break
   
   
    case 4:
    msg =& str4;
    count++;
    break
   
    case 5:
    msg =& str5;
    count++;
    break
    case 6:
    msg =& str6;
    count=0;
    break;
    }
     }
   
   
   
   Serial.println("connecting ...");
  if (twitter.post(*msg)) {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait(&Serial);
    if (status == 200) {
      Serial.println("OK.");
    } else {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } else {
    Serial.println("connection failed.");
  }

 
 



 void alarm()
 {
  ledState = HIGH;
   
 }
28  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 11:53:52 am
yes, but i need an array with pointer, so in the switch case depending on the counter, the pointer msg will be referenced to the array with the message

Code:
char* msg
its the pointer i need..
29  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 10:21:55 am
 i used that because IDE told that that if i use
Code:
char* msg[];
then the zise its unknown,

still the error says that i need an initializer before if  functions....

also doesnot allow me to use the normal { on the start of the void loop()..... so im not sure where its my mistake... maybe i have many of then
30  Using Arduino / Programming Questions / Re: help with alarm code on: March 14, 2013, 08:57:04 am
this is my code but i doesnt compile, i cant find the error...

Code:
#include <SPI.h> // needed in Arduino 0019 or later
#include <Ethernet.h>
#include <Twitter.h>

// The includion of EthernetDNS is not needed in Arduino IDE 1.0 or later.
// Please uncomment below in Arduino IDE 0022 or earlier.
//#include <EthernetDNS.h>

int LedState=LOW ;
// Ethernet Shield Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// If you don't specify the IP address, DHCP is used(only in Arduino 1.0 or later).
byte ip[] = { 192, 168, 2, 250 };

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("YOUR-TOKEN-HERE");

// Message to post
char* msg[20];
char str1[]="post one";
char str2[]="post two";
char str3[]="post three";
char str4[]="post four";
char str5[]="post five";
char str6[]="post six";

void setup()
{
  digitalWrite(2, HIGH);
  attachInterrupt(0, alarm, RISING);
 
  delay(1000);
  Ethernet.begin(mac);
  // or you can use DHCP for autoomatic IP address configuration.
  // Ethernet.begin(mac);
  Serial.begin(9600);
 
 

void loop()

 int count=0;
  if (ledState == HIGH)
  {
    LedState==LOW;
   
    Swtich (count)
    { case 1:
    msg =& str1;
    count++;
    break
   
    case 2:
    msg =& str2;
    count++;
    break
   
    case 3:
    msg =& str3;
    count++;
    break
   
   
    case 4:
    msg =& str4;
    count++;
    break
   
    case 5:
    msg =& str5;
    count++;
    break
    case 6:
    msg =& str6;
    count=0;
    break;
    }
     }
   
   
   
   Serial.println("connecting ...");
  if (twitter.post(msg)) {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait(&Serial);
    if (status == 200) {
      Serial.println("OK.");
    } else {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } else {
    Serial.println("connection failed.");
  }

 
  }



 void alarm()
 {
  ledState = HIGH;
   
 }
Pages: 1 [2] 3 4 ... 23