Controlling eletronic devices with JAVA ( LEDS, MOTORS...)

All this week I try to find some help about how to control eletronic devices like leds using the parallel or serial port using JAVA. Using C it's very simple, but with JAVA, I guess that NOBODY do this kind of application... If I'm wrong, please, tell me.... ( I know that I need to use javax.comm or JNI, but I want to see a real application that works ...

First thing to note is that using javax.comm you cannot set pin outputs
levels directly (you can set some pin levels directly such as CTS and
RTS on a serial port). There are ways around this such as writing the correct byte value to the parallel port (depends on port type though)
Therefore the device you wish to communicate with should be able
to talk to parallel or serial ports. If this is the case you just send
messages to the device and it lights up you leds.
A, perhaps better, solution would be to write, or obtain from the
internet, some native lib that allows bit bashing on the port of your
choice. Then write a wrapper class for it an call its methods (JNI).
This is only worth while if you have some reason to use java rather
then another language, such as C or C++, to talk to you device. This
whole thing would probably be easier in one of those languages.
matfud

Similar Messages

  • About: control USB device with Java

    Any body know how to control USB device with Java?
    Does JDK provide a package for USB?
    Is there any web site concerning USB programming?
    Thank you! ^_^

    Look at www.prosyst.com. There is an usb bundle (linux
    and windows pltforms).I looked on this site and cannot find the bundle you are talking about. Do you know more specifically where to find out about controlling USB devices with Java?

  • Controling another program with java

    hi. i have some problems about java. i'm trying to control a program with my java codes.i'm trying to explain that i will write a program and this program will send some keys to another choosen program. forexample i will say my program that i want you to send "A" key to a game for 500 times and at the game my program will write AAAAAAA....... .i look for some examples in c++. c++ uses findwindow and postevent methods for this work but i couldn't find anything.
    so i want some help about this
    what can i do or where can i find some help
    sorry about my little english.
    thanks...

    look up the Robot object in Java 1.31 (I think) or later.

  • How to control tcp connection with java tcp socket programing ??

    Hi,
    I am connecting a server as using java socket programming.
    When server close the connection (socket object) as using close() method ,
    I can not detect this and My program continue sending data as if there is a connection with server.
    How to catch the closing connection ( socket ) with java socket programming.
    My Client program is as following :
    import java.io.PrintWriter;
    import java.net.Socket;
    public class client
      public client()
       * @param args
      public static void main(String[] args)
        Socket socket=null;
        PrintWriter pw=null;
        try
                          socket = new Socket("localhost",5555);
                          pw = new PrintWriter(socket.getOutputStream(),true);
                          int i=0;
                          while (true)
                            i++;
                            pw.println(i+". message is being send.");
                            Thread.sleep(5000);
        } catch (Exception ex)
                          ex.printStackTrace();
        } finally
                          try
                            if(pw!=null)pw.close();
                            if(socket!=null)socket.close();
                          } catch (Exception ex)
                            ex.printStackTrace();
                          } finally
    }

    I changed the code as following. But I couldn't catch the EOFException when I read from the socket. How can I catch this exception ?
    import java.io.BufferedReader;
    import java.io.EOFException;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.net.Socket;
    import java.net.UnknownHostException;
    public class client
      public client()
       * @param args
      public static void main(String[] args)
        Socket socket=null;
        PrintWriter pw=null;
        BufferedReader bufIn=null;
        InputStreamReader inRead=null;
        InputStream in=null;
        try
                          socket = new Socket("localhost",5555);
                          in = socket.getInputStream();
                          inRead = new InputStreamReader(in);
                          bufIn = new BufferedReader(inRead);
                          pw = new PrintWriter(socket.getOutputStream(),true);
                          int i=0;
                          while (true)
                            i++;
                            try
                              bufIn.readLine();
                              pw.println(i+". message is being send.");
                              System.out.println(i+". message has been send");
                            } catch (Exception ex2)
                              System.out.println(ex2.toString());
                              System.out.println(i+". message could not be send");
                            } finally
                            Thread.sleep(5000);
        } catch (EOFException ex)
                          ex.printStackTrace();
        } catch (InterruptedException ex)
                          ex.printStackTrace();
        } catch (IOException ex)
                          ex.printStackTrace();
        } finally
                          try
                            if(pw!=null)pw.close();
                            if(socket!=null)socket.close();
                          } catch (Exception ex)
                            ex.printStackTrace();
                          } finally
    }

  • VRML EAI with Java

    Hi,
    I am currently working on VRML. I like to control VRML world with Java world. Following is the simple Java program that controls VRML world. Now the problem is when i compile it using JDK1.4.2, it compiles well if i use Cortona plug ins. But when i want to see the applet from Internet Explorer 6.0, it is mentioning "ClassnotFound". Following are the VRML and HTML files. I want to be more precise. In my internet explorer, i am checking for Java Virtual Machine option instead of Microsoft VM. I have set classpath accordingly. When i am compiling the class with JDK, its bytecode becomes compatible with JVM. Now, how can i run this applet which is using VRML world. I am waiting forward to hearing from any genious.
    // Simple applet illustrating use of add/removeChildren fields.
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import vrml.external.field.*;
    import vrml.external.Node;
    import vrml.external.Browser;
    import vrml.external.exception.*;
    public class AddRemoveTest extends Applet implements ActionListener {
    TextArea output = null;
    boolean error = false;
    // Browser we're using
    Browser browser;
    // Root of the scene graph (to which we add our nodes)
    Node root;
    // Shape group hierarchy
    Node[] shape;
    // EventIns of the root node
    EventInMFNode addChildren;
    EventInMFNode removeChildren;
    // Add and Remove Buttons
    Button addButton;
    Button removeButton;
    public void init() {
    add(addButton = new Button("Add Sphere"));
    add(removeButton =new Button("Remove Sphere"));
    addButton.addActionListener(this);
    removeButton.addActionListener(this);
    output = new TextArea(5, 40);
    add(output);
    browser = Browser.getBrowser(this);
    try {
    // Get root node of the scene, and its EventIns
    root = browser.getNode("ROOT");
    addChildren = (EventInMFNode) root.getEventIn("addChildren");
    removeChildren = (EventInMFNode) root.getEventIn("removeChildren");
    // Instantiate our ubiquitous blue sphere hierarchy
    shape = browser.createVrmlFromString("Shape {\n" +
    " appearance Appearance {\n" +
    " material Material {\n" +
    " diffuseColor 0.2 0.2 0.8\n" +
    " }\n" +
    " }\n" +
    " geometry Sphere {}\n" +
    "}\n");
    catch (InvalidNodeException e) {
    output.append("PROBLEMS!: " + e + "\n");
    error = true;
    catch (InvalidEventInException e) {
    output.append("PROBLEMS!: " + e + "\n");
    error = true;
    catch (InvalidVrmlException e) {
    output.append("PROBLEMS!: " + e + "\n");
    error = true;
    if (error == false)
    output.append("Ok...\n");
    public void actionPerformed (ActionEvent event) {
    Object clickedButton = event.getSource();
    if (clickedButton == addButton) {
    addChildren.setValue(shape);
    else if (clickedButton == removeButton) {
    removeChildren.setValue(shape);
    =====================
    ++++Here is the VRML file++++
    #VRML V2.0 utf8
    DEF Camera Viewpoint {
    position 0 0 7
    DEF ROOT Group {}
    =====================
    ++++ Here is the simple html file+++++
    <html>
    <head>
    <title>Add/Remove Children Test</title>
    </head>
    <center>
    <embed src="root.wrl" border=0 height="250" width="600">
    </center>
    <applet code="AddRemoveTest.class" mayscript>
    </applet>
    </html>

    You can download the microsoft vm from microsoft, its easy to find from google. Once you have installed it, go to tools>internet options. On the advanced tab, deselect the Java (Sun) checkbox, and check all of the microsoft vm checkboxes. This might work..............
    However, I have performed these steps, tested them and now tried to upload a similar applet to control a VRML world. I am again getting the error message "load: cannot load class". So if anyone can help I think you can save my sanity........PLEASE!

  • Device control software with Java?

    Hi there,
    i don't know if this is the correct forum for my answer, but I'll just give it a try.
    I am confronted with the task of developing a fat-client-software for windows-based PCs, for receiving and handling data coming from complex, lab-like devices.
    Is Java a good choice for such a task and what kind of architecture, framework, library would you recommend?
    Thanks in advance,
    Xenofon

    kajbj wrote:
    mk637 wrote:
    Can you please be more specific? What information do you need?I don't need any information. Yuo need to check if you can access those devices from Java in any way.Ok. But do you need to implement all of the communication, or do they provide client libraries that handles it for you? What languages do they in that case support?

  • Can Wireless Home Audio products be controlled via IP with any other devices?

    I'm interested in knowing if the Wireless Home Audio Director, Conductor or Player can be controlled via IP with alternative controllers?  Specifically, I'm interested in integrating the products into a universal remote control or home control system and still have 2 way communications with feedback.  IP and RS232 are the most commons ways of accomplishing this.

    Hi,
    Maybe for basic functions like (play, stop, next) using the IR remote, a third party IR based universal remote may work but that's a big gamble to take, anyway what would be the purpose then of the Linksys DMRW1000 (IP based remote control) remote that Linksys is selling if its compatible with third party remotes.
    Wireless Home Audio remote
    Well that's my thoughts on this, I hope you'll find the device your looking for.

  • Sending data during the call with java enabled mobile devices

    hi every one ,
    this is the problem :
    i have 2 mobile phone with java enabled os , i want to call (dial) from phone1 to phone2 with java code , (this will be done by platformRequest("tell:123456"))
    AND then i want to for example press key '1' in phone1 during the call some program send this key to phone2 and in phone2 i want to switch this key and understand that was key '1' ...
    how can i send this data for example a key pressed event to another phone with J2ME ???
    i am developing it with netbeans Mobile Application by the way ...
    could you please tell me your opinion and help me in this ,
    Thanks a lot ,
    Omid

    Hi Kanagaraja L,
    Thanks for you response.
    No I haven't created Created RFC Destination , this RFC destination will be of my JAVA system ???.
    I have tried creating the partner logical system in WE20 and dine the following steps:
    1. Partner No.   IDES800     Ides 800 System - Sender System
        Partn.Type    LS          Logical system
    2. The tab Post processing : permitted agent is filled with default parameters.
    3. Then in the outbound parameter table control I have pressed the add record button and got a new screen in
        which I have made the following entry :-
      Partner No.           IDES800        Ides 800 System - Sender System
      Partn.Type            LS             Logical system
      Partner Role          LS             Logical system
        Message Type      SYNCH                            ALE:Dummy Message Type for De
        Message code
        Message function
    Under tab Outbound options :
    Receiver Port  = A000000008  (This I have selected from F4 help)
    Basic type = SYNCHRON
    Saved it with the above data.
    Now I am not able to understand how to do the things you have mentioned in 3rd step in your reply.
    What are all the things I have to do kindly tell , as I am very new to Idocs so don't have much knowledge.
    Edited by: Rachit Khanna on Dec 7, 2009 1:49 PM

  • On certain web sites(with java applets embedded or rich content),sometimes browser hotkeys are beeing used with other functionality (eg.: youtube uses ctrl + tab for sliding between player controls).How can I prevent this?

    On certain web sites(with java applets embedded or rich content),sometimes browser hotkeys are beeing used with other functionality (eg.: youtube uses ctrl + tab for sliding between player controls).How can I prevent this ?

    Thanks for posting this!
    I would only mention that your definition is incomplete for this -
    Contextual selector A type of Style Sheet Selector that
    and that it's most often referred to now as a Descendent selector, not a contextual selector.  It's basically the same as the Compound selector that you have already defined....

  • HT1904 if i purchased my device with my money is it legal for someone else to put on the parental controls?

    if i purchased my device with my money is it legal for someone else to put on the parental controls?

    That is an interesting question.  If you are at the "age of majority", then why would you allow someone else to put restrictions on your device..  If it is a condition of your employer to use the device on their network services, then you allow it to use the device for their system.  If you are under the age of majority, and your parents are requiring it, sounds like the parents care.

  • Replace VBX Control with Java Bean

    Hi All,
    While compiling 6i forms in 10g I got this error of VBX Control (Obsolete)
    The document says replace it with JavaBeans.
    I don’t know how to replace a VBS Control with Java Bean but this is what I did, I selected the item type as Bean Area.
    But the item do have a trigger
    begin
    control_lib.when_tab_changed(:control.tab_ctl)
    end
    The Package CONTROL_LIB is coded as below.
    Will this code work, technically I think yes, but its always better to ask experts before I move this to test...
    package body control_lib is
    g_tab_id number := 0
    procedure when_tab_changed
    (p_tab_id number) is
    l_err_txt varchar2(255);
    begin
    if :system.block_status != 'QUERY' then
    if not good_quiet_post(l_err_txt) then
    raise form_trigger_failure;
    end if
    end if
    if p_tab_id = 0 then
    rpt_ln_lib.new_tab;
    elsif p_tab_id = 1 then
    stat_lib.new_tab;
    elsif p_tab_id = 2 then
    per_acc_rl_lib.new_tab;
    end if
    g_tab_id := p_tab_id
    exception
    when form_trigger_failure then
    :control.tab_ctl := g_tab_id
    synchronize
    end when_tab_changed
    Thanks to all.
    Habeeb

    A Java bean is another technology than VBX control.
    If some document says: Replace it with java bean it certainly means to use a similar java bean with a similar functionality.
    I do not know a java bean, which runs VBX controls.
    So you surely have to look at what yout VBX does an than to look after a proper java bean (or to write an own one).

  • Mounting devices in linux with java

    I am writing an application that is remotely like file-manager. In some situations that app needs to mount devices in Linux environment (run *nix-commands like 'mount /media/sda1' ) to ensure that attached devices are really available.
    How can this be done with Java.
    Thanks,
    Pete

    Runtime.exec lets you execute a native app, for more details and things that will likely go wrong see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    An option would be using JNI and writing a wrapper for the C-function. Without a doubt someone has already done this, so, as always... google is your friend... http://www.google.fi/search?q=java+unix+mount
    This looks promising: http://www.xenonsoft.demon.co.uk/products/javaunix/

  • [Desktop][Connect] Control Spotify Connect Devices With Desktop App

    Recently, Spotify Connect enabled controlling the desktop app with a mobile device, but this is not complete!
    Allow the controlling of Spotify Connect devices with the Destop App. For example I can control a mobile device from my PC, or I can control the PlayStation app from my PC. 
    Right now I run a virtual machine with a virtual tablet to run the Spotify Mobile app to use Spotify Connect to control devices from my PC, when I should be able to use the desktop app in the first place.

    Updated: 2015-06-30Hello!
    This should already work - as a matter of fact I'm just controling my smartphone via my Desktop atm.
    Could you please tell us what devices you're using and which Spotify versions you've got installed on there? Also are you on the same network on both devices?

  • HT204368 Can you (Handoff) control your iphone with 3rd party devices ? (Like making calls, sending message, etc...)

    I am wondering if you can control your iphone or other iOS devices with 3rd party devices? I have in mind like making calls, sending sms, etc....
    Thank you!

    No,

  • How can I control external devices using a touch screen with a standalone LabVIEW app

    For my senior design project my group and I created a hybrid extended range vehicle with 90 Li+ Batteries thats charged by a 15 kW generator and/or that is also being charged by a 5 kW fuel cell. Currently, our system is capable of measuring voltages off of the batteries and displaying them on a laptop via LabVIEW. To process this data, we are using a cRIO FPGA. What we would like to do now is have a touch screen for the driver to choose what power source charges the batteries as well as monitor a pressure reading coming from the fuel cell tank. 
    What sort of small touch screens allow for LabVIEW to be uploaded on and used for controls?
    Does a cRIO have the capability to power such a screen and handle the data transfer from the fuel sensor and switching relays (for switching on and off powersources)? 
    Do I need an additional license for creating standalone applications and how would i go about creating a standalone app?
    sorry for so many question. Any reply helps. Thanks!
    Solved!
    Go to Solution.

    That sounds like a pretty interesting project.  If you are interested, National Instruments hosts a Student Design Competition where you can win cash or a trip to Austin for NIWeek.
    steve215 wrote:
    What sort of small touch screens allow for LabVIEW to be uploaded on and used for controls? 
    NI does sell Touch Panel computers that can be used to control LabVIEW applications.  You can find more information here: HMIs and Industrial Touch Panels and here: LabVIEW Real-Time and Touch Panel Deployment and Replication Resources. Our 6-inch touch panel computers run Windows CE, so programming on them is a little different than programming on a full Windows OS.  You may find the Getting Started with the LabVIEW Touch Panel Module useful.
    You can use third party devices with the LabVIEW Touch Panel Module, although you will need a deployment license for it.  More information can be found in the getting started guide.
    If you were able to send the cRIO information over a network (which from your description sounds unlikely), you may be able to use a smartphone to control your application.  More information can be found on our Community Smartphone Group.
    steve215 wrote:
    Does a cRIO have the capability to power such a screen and handle the data transfer from the fuel sensor and switching relays (for switching on and off powersources)? 
    If you were using the 6-inch touch panels, they require 18 to 32 VDC (the fuse becomes an open circuit if input level exceeds 33 VDC).  The data transfer from the switching relays can be monitored and changed with the touch panel.
    steve215 wrote:
    Do I need an additional license for creating standalone applications and how would i go about creating a standalone app? 
    If you went the touch panel route, you would need to purchase the LabVIEW Touch Panel Module, and a touch panel.  The NI touch panels come with a touch panel deployment license.  Step-by-step guides for creating the standalone app can be found in the Getting Started with the LabVIEW Touch Panel Module guide. 
    Regards,
    Elizabeth K. 
    National Instruments | Applications Engineer | www.ni.com/support 

Maybe you are looking for