5

I have just bought an Arduino Uno and I am currently trying to make a flashing LED. I was wondering how I could do this, and I have looked at the Arduino Playground and have found a program to get input. I need to output to the Arduino. It is not possible for me to use anything but Java because I already have another program that requires an Arduino. Please leave any ideas.

Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
cheese5505
  • 962
  • 5
  • 14
  • 30
  • 2
    Have you checked http://arduino.cc/playground/Interfacing/Java ? – jayeff Jul 03 '12 at 08:13
  • Yes, that is the website I saw. But that only has information on getting input, I want to output. – cheese5505 Jul 03 '12 at 08:15
  • I'm confused? You want to control the flashing led via your computer to the arduino using java? Or do you want a Java development environment? Please explain what your trying to do and how your doing it. – Hellonearthis Jul 03 '12 at 08:48
  • I want to control the flashing led connected to the Arduino with Java. The Arduino IDE is not an option because I already have another java program I am going to use the Arduino for. – cheese5505 Jul 03 '12 at 22:19
  • @jayeff +1 for good suggestion. You are correct. I quoted you in my answer below. Post it as an answer and I'll +1 it. OP should select that as the answer. – ZnArK Jul 05 '12 at 20:34

1 Answers1

0

EDIT: Kind of sounds like you want to do this in java.

And excerpt from the site mentioned by jayeff:

The OutputStream comes with 3 different write methods to send data from the computer to the Arduino. In the above example, you could use output.write(String) to send data, as in output.write("Hello Arduino!").

If you're trying to use Java to write to the Arduino, then this is your answer.

http://arduino.cc/playground/Interfacing/Java


EDIT: If you want to use something other than Java, here you go:

Ask and you shall receive. You can do this in any programming language that has serial support.

There are certainly other methods for each language, but here are some I found in 5 minutes at the Google Machine

Note: Watch out for the nasty Auto Reset on Serial issue. See my previous answer for more details on that.

Here's my C++ Code (it's ugly but it works)

#include <SerialStream.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
class SerialComm {
    LibSerial::SerialStream myss;
public:

    SerialComm(int argc, char** argv) {
        myss = new LibSerial::SerialStream("/dev/ttyS0", ios_base::out);
        myss.SetBaudRate(LibSerial::SerialStreamBuf::BAUD_57600);
        myss.SetCharSize(LibSerial::SerialStreamBuf::CHAR_SIZE_8);
        myss.SetFlowControl(LibSerial::SerialStreamBuf::FLOW_CONTROL_NONE);
        myss.SetParity(LibSerial::SerialStreamBuf::PARITY_NONE);
        myss.SetNumOfStopBits(1);

        const int Dsize = 2;
        char buffer[1];
        buffer[0] = 125; //0b00000001;
        buffer[1] = '\0';
        bitset(buffer[0]);
        //myss << buffer;
        myss.write(buffer,1);
        //myss.Close();

    }
}
Community
  • 1
  • 1
ZnArK
  • 1,533
  • 1
  • 12
  • 23
  • Thanks, This was a good idea but I did it a different way by making the arduino output for the amount of milliseconds that I write to the serial port. – cheese5505 Jul 25 '12 at 07:37