Hi, I am very new to the Arduino scene. I am currently working to get my Arduino to tweet. I have my ethernet shield and twitter library up and i can successfully tweet when a button is pressed. However I cannot seem to get my arduino to accept anything other than a string for char msg[]
when i try to put char msg[] = "hello" + "goodbye", i get
error: invalid operands of types 'const char [6]' and 'const char [8]' to binary 'operator+
when i try and tweet a random number, char msg[] = "hello" + random(100), i get
error: initializer fails to determine size of 'msg'
Why cant i use anything other than a single string for my tweeted message?
Here is my code, and thanks for your help!
#include <Ethernet.h>
#include <EthernetDHCP.h>
#include <EthernetDNS.h>
#include <Twitter.h>
const int buttonPin = 2;
int buttonState = 0;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 130, 65, 114, 80 };
byte gateway[] = { 130, 65, 114, 254 };
byte subnet[] = { 255, 255, 255, 0 };
// Your Token to Tweet
Twitter twitter("my token");
// Message to post
char msg[ ] = "hellogoodbye";
void setup()
{
pinMode(buttonPin, INPUT);
delay(1000);
Ethernet.begin(mac, ip, gateway, subnet);
Serial.begin(9600);
Serial.println("I am connecting ...");
}
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.println("button pressed");
if (twitter.post(msg)) {
int status = twitter.wait();
if (status == 200) {
Serial.println("Tweeted!");
} else {
Serial.print("failed : code ");
Serial.println(status);
}
} else {
Serial.println("connection failed.");
}
}
else {
}
}