Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35483
Seattle, WA USA
|
 |
« Reply #30 on: March 14, 2013, 02:04:42 pm » |
char* msg[26]; This is STILL wrong. 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() Curly braces are NOT optional and not wherever the heck you feel like putting them. The compiler is right. You DO have stuff before the if statement that doesn't belong there.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Sr. Member
Karma: 1
Posts: 333
UNO
|
 |
« Reply #31 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 char *msg; still the compiler says im wrong in the if funtion #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; }
|
|
|
|
« Last Edit: March 14, 2013, 02:25:46 pm by copachino »
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19030
I don't think you connected the grounds, Dave.
|
 |
« Reply #32 on: March 14, 2013, 02:29:01 pm » |
What do you see as the first thing after "void loop ()"? What do all correct sketches have that you do not?
Note also that LedState is not the same as ledState. That may be important.
Also, "switch" needs to be spelled correctly, and not capitalised.
|
|
|
|
« Last Edit: March 14, 2013, 02:31:39 pm by AWOL »
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Sr. Member
Karma: 1
Posts: 333
UNO
|
 |
« Reply #33 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
|
|
|
|
« Last Edit: March 14, 2013, 02:39:44 pm by copachino »
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19030
I don't think you connected the grounds, Dave.
|
 |
« Reply #34 on: March 14, 2013, 02:33:08 pm » |
Really?
There was a comment earlier about braces being in the right places, and matching.
This is also important.
|
|
|
|
« Last Edit: March 14, 2013, 02:34:41 pm by AWOL »
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Sr. Member
Karma: 1
Posts: 333
UNO
|
 |
« Reply #35 on: March 14, 2013, 02:41:48 pm » |
yes now the main problem its the pointer #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; }
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19030
I don't think you connected the grounds, Dave.
|
 |
« Reply #36 on: March 14, 2013, 02:42:57 pm » |
yes now the main problem its the pointer Don't hold back - feel free to share.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Sr. Member
Karma: 1
Posts: 333
UNO
|
 |
« Reply #37 on: March 14, 2013, 02:44:31 pm » |
yes now the main problem its the pointer Don't hold back - feel free to share. this are tyhe errors the compilers shows 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*)'
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19030
I don't think you connected the grounds, Dave.
|
 |
« Reply #38 on: March 14, 2013, 02:46:27 pm » |
"msg"" is a "char", not a "char" pointer.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Sr. Member
Karma: 1
Posts: 333
UNO
|
 |
« Reply #39 on: March 14, 2013, 02:48:42 pm » |
you mean something like this??? char* msg;
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19030
I don't think you connected the grounds, Dave.
|
 |
« Reply #40 on: March 14, 2013, 02:49:57 pm » |
Why ask me? What does the compiler say?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Sr. Member
Karma: 1
Posts: 333
UNO
|
 |
« Reply #41 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... 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
|
|
|
|
|
Logged
|
|
|
|
|
Finland
Offline
Jr. Member
Karma: 1
Posts: 84
|
 |
« Reply #42 on: March 14, 2013, 03:40:17 pm » |
you mean something like this??? char* msg; Is that what you tried and got all those errors? It looks most correct for what you seem to be trying to do. It's a pointer. Initialize it to 0 just in case. Next you need to see what code sits on the line number it whines about, if it still does. I suspect the error messages point to all the lines where you are trying to assign something to msg and that's what you tinker. I can't tell off the top of my head at this hour what's it supposed to read for what you are doing there. I assume you are trying to assign the other array pointers to the msg one, so do that. It's only going to work if twitter.post(msg) accepted a char pointer. I can see it takes a const char pointer judging by the error message. Well, see what the compiler tells you anyways without making too many changes at once between each compilation. Another thing, if you end up getting a whole bunch of text posted (all of the strings), you probably need a null ending character \0 at the end of the string of characters. Or maybe not, I forget as I rarely have to deal with char arrays in C these days. Can you find out and post your findings?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19030
I don't think you connected the grounds, Dave.
|
 |
« Reply #43 on: March 14, 2013, 03:45:12 pm » |
*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.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
California
Offline
Edison Member
Karma: 38
Posts: 1850
|
 |
« Reply #44 on: March 14, 2013, 03:56:01 pm » |
Edit: I'm behind the times.
|
|
|
|
|
Logged
|
|
|
|
|
|