To do that I have used a computer with Ubuntu 12.04 and the program language C++, but if you want to used Windows the code works too, only have to change the port used to conect with arduino, but this is explain in the next step.
This program is only the first version so it must be improved.
Arduino use the usb port to simulate a serial port so we have to use a usb cable to connect the arduino usb port to computer usb port.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Program in C++
This is the code of C++, I have created a main class and a Arduino class, so this is object oriented.
string dev = "/dev/ACM0";
#endif // ARDUINO_H
This is the header of Arduino class.
There are three functions open, read and close.
Open: Open the conection bewteen arduino and the computer.
Read: Read the bufer where is all dates that arduino has send to the computer.
Close: Close the conection bewteen arduino and the computer.
To connect with arduino I have used the port of my computer "/dev/ACM0", if you use Windows instead of Linux you have to use the port "COM1" or "COM2". But to see what port is using arduino you have to use the JDK of arduino and select a port in "Tools -> Serial Port".
# include <Arduino.h>
int estado = 0;
if (serial.IsOpen() == false)
estado = -1;
serial.Read(buffer, 10, 1000);
This is the code of Arduino class.
using namespace std;
using namespace LibSerial;
int main(int argc, char **argv)
And finally this is the main class.
Step 2: Program in Arduino
This is the code that you have to do in arduino.
This code is very simple.
"Serial.begin(9600)" : Sets the velocity of dates in bits per second (baud).
Serial.println("Hello world") : Send a message through the serial port.
delay(1000) : Stop by 1000 miliseconds.
Participated in the