I've actually made a library for you, if you're interested.
This is an example of usage:
http://arduino.pastebin.com/f3b6a0334It will enable you to send command strings through serial, and the arduino will act upon them.
My library consists of three classes/structs
- Tool - definition of a single tool
- Toolkit - collection of tools
- ToolUser - a user of a toolkit
If you send
+Spanner10$ it will add a spanner10 to a user
If you send
-Spanner10$ it will remove a spanner10 from a user
I imagine there are a few functions that you would like to add to the API.
Maybe a
getNumberOfTools() for knowing how many tools a user has, or a
has(tool); to find out if a user has a tool.
You are free to edit the source and do whatever you want with it. If you have questions, PM me or use the @contact from the example.
This is a Serial log from a testrun of the example sketch that comes with the library.
You can add or remove tools by usnig these commands:
+SpannerXX$
-SpannerXX$
Where:
+ and - indicates the wanted operation (add / remove)
XX could be either 8,10,12 or 14
$ indicates command end
Write '+Spanner10$' in order to add spanner10
Write '-Spanner10$' in order to remove spanner10
Tools in toolkit:
spanner8
spanner10
spanner12
spanner14
mlaser has these tools:
spanner8
spanner12
spanner14
//sent: +Spanner10$
//result:
mlaser has these tools:
spanner8
spanner12
spanner14
spanner10
//sent: -Spanner10$
//result:
mlaser has these tools:
spanner8
spanner12
spanner14
[size=14]Donwload
here[/size]
[edit][size=12]A quick example:[/size]
#include <Toolkit.h> //http://hosting.alexanderbrevig.com/arduino/libraries/Toolkit.zip
//initialize some tools
Tool spanner8 = Tool("spanner8");
Tool spanner10 = Tool("spanner10");
//prepare the toolkit
Toolkit toolkit;
//initialize a user
ToolUser mlaser = ToolUser("mlaser",toolkit); //user name is mlaser, and this user can use tools from the Toolkit named toolkit
void setup() {
Serial.begin(9600);
//add tools to the toolkit
toolkit.addTool(spanner8);
toolkit.addTool(spanner10);
//ask toolkit for spanner8 and spanner10
mlaser.request(spanner8);
mlaser.request(spanner10);
mlaser.printTools();
/* prints:
mlaser has these tools:
spanner8
spanner10
*/
//ask toolkit to recieve spanner8
mlaser.replace(spanner8);
mlaser.printTools();
/* prints:
mlaser has these tools:
spanner10
*/
}
void loop(){
}
[/edit]