Arduino Serial Interface
With this serial interface you'll be able to send commands from a console in your PC to the arduino. You can also define your own commands for the arduino.
In this example we use a desktop console app and an arduino program to move a servo attached to the Arduino.
Send the "servo" command from our desktop app to the arduino program, and type the desired angle. The arduino board connected via USB will do the rest!
How does it work?
Just need to use the methods
write to communicate with the device through serial port. Those functions and the whole API definition are defined in david/serial_arduino and david/serial_cpp libraries.
How do I use it?
You need to create two projects arduino_app and cpp_app, one will contain the code that will be uploaded to arduino and the other one the client application that will run in your PC.
$ bii init cpp_app
$ bii init arduino_app
$ cd cpp_app $ bii open examples/serial_interface_cpp
$ cd arduino_app $ bii open examples/serial_interface_arduino
Change the Serial Port ID in the main_cpp.cpp file with the one you are using with the arduino.
.. literalinclude:: ../../_static/code/arduino/examples/serial_interface/main_cpp.cpp :language: cpp
.. literalinclude:: ../../_static/code/arduino/examples/serial_interface/main_arduino.cpp :language: cpp
Build and run!
Execute following commands in each project:
$ bii arduino:settings ... $ bii configure -t arduino ... $ bii build ... $ bii arduino:upload
$ bii build $ cd bin $ #run solver executable Enter: servo servo Enter: 180 180 Enter: servo servo Enter: 90 ...
Now you can start hacking your own commands!