I have decided to make a nightlight that will connect to twitter, and I will just have it controlled by it by it reading the posts. So here's the problem. How do I take data such as this 255, 245, 103 etc. and assign it RGB values? By which I mean, how do extract the first number and assign it to a int, and same for the rest so I can light a led accordingly?
By the way as soon as this is finished it will go to the twitter account WifiNightLight.
char *token = NULL;
char *stringToParse = "123, 456, 789";
int vals[3];
int valCnt = 0;
token = strtok(stringToParse, ",");
while(token)
{
// Do something with this token
vals[valCnt] = atoi(token);
valCnt++;
// Get the next token
token = strtok(NULL, ",");
}
I think it goes without saying that error checking (reading 14 values, for instance) needs to be added. This is just to give you an idea of how to use the atoi and strtok functions.
Cool! But now another problem shows up.
here's what it says
Error Compiling.
:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:3:27: error: NewSoftSerial.h: No such file or directory
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:6: error: 'NewSoftSerial' does not name a type
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::begin(uint16_t)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:27: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'uint8_t AF_XPort::reset()':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:43: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'uint8_t AF_XPort::connect(char*, long int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:65: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'uint8_t AF_XPort::serialavail_timeout(int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:86: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'uint8_t AF_XPort::readline_timeout(char*, uint8_t, int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:114: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::flush(int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:133: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::ROM_print(const char*)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:148: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::print(uint8_t)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:153: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::print(const char*)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:154: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::print(char)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:155: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::print(unsigned int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:156: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::print(long int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:157: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::print(long int, int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:158: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::println()':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:159: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::println(const char*)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:160: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::println(uint8_t)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:161: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::println(int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:162: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::println(long int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:163: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::println(long unsigned int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:164: error: 'xportserial' was not declared in this scope
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp: In member function 'void AF_XPort::println(long int, int)':
C:\Documents and Settings\chris.JOHNSTON\Desktop\Programming Programs\arduino-0018\libraries\AF_XPort\AF_XPort.cpp:165: error: 'xportserial' was not declared in this scope
It looks like I need to add some libraries that I have already added....
This problem has been going on for every single Ladyada Ethernet shield kit examples.... could it be I'm missing a library?