If you just want to be able to control something 'real' with Java one possibility is a model railway. Have a look at the JMRI project http://jmri.sourceforge.net/ and for a cheap hardware interface http://www.sprog-dcc.co.uk/
The sprog interface is only one way (no feedback from the devices), but other systems can provide two way information.
The motors, lights and other features in each train a managed by a microcontroller (as little as Â£10 each). Although intended for model railway control, these devices could be fitted in other systems.
Later: Actually the SPROG can read back information from the microcontroller in programming mode. This allows the registers on the device to be read and modified (there can be dozens of such registers). With JMRI this is all done in Java.
Message was edited by: mthornton
mthornton, thatâ€™s a really good idea. (Iâ€™ve seen some really good ideas looking through the posts, and Iâ€™m still looking through all of the links provided for code that reads a peripheral!) Do you know if the code for the microcontroller that you mentioned would work with any microchip? It is mostly the code that Iâ€™m interested in - because I already have a microchip with potentiometers and switches. Once I find and modify a code - to make this code able to read information from this microchip, then I can modify all of my Java homework assignments to read these potentiometers and switches. I should probably have specified that this microchip is connected via a USB port.
Current versions of the SPROG are connected via USB. I think the USB connection hardware takes the form of a USB to serial to converter followed by a basic PIC controller. It may be that your device is similar. If so an inspection of the JMRI code might yield some ideas.
You might want to look at Phidgets http://www.phidgets.com/ which provides switches, knobs, RFID readers etc and provides a Java API. Or if you don't mind getting your hands dirty doing a bit of electronics, try Arduino Diecimilia http://www.arduino.cc/ which is a micro-controller board which is programmable in the Processing environment http://www.processing.org/ which is based on Java.
Note: as of now, there are no more than 13 new replies to this post.
Jason - I suspect that learning to program a computer by using things like switches and pots attached to a computer via some microelectronics isn't going to work well for you. There are a bunch of technical reasons for this that I won't go in to. Suffice to say - going this route is going to make life difficult for you because it doesn't work like you think it works.
If you want to learn Java in a "hands on" way, I'd suggest you take a look at BlueJ. It's designed to let people learn Java programming in an interactive way by experimenting and exploring the BlueJ environment.
psynixis, Thanks. I looked through the Chapter sequence of â€œObjects First with Java A Practical Introduction using BlueJ.â€ Though I couldnâ€™t understand everything that was written, I didnâ€™t find anything about peripheral programs â€“ or peripheral example code â€“ which is what I am looking for. For school class â€“ and I am a first year student, we are using â€œjava Software Solutionsâ€ by Lewis & Loftus. I may not have communicated clearly. For anyone who may be reading this, my goal is not to focus on peripherals, but to learn how to read a couple of analog output pins on a USB development board. Actually, I donâ€™t even need to learn how to develop a program to read a peripheral now. I am just looking for a code that I can dissect that has a couple variables that can read my peripheral. That way, I can use these variables in programs that are on my level of developing â€“ which is my goal.
Unfortunately, I have to agree with p3aul. I am a hard core Java programmer and have been for several years. However, Sun's support for common USB devices such as digital cameras, scanners, and so on is very disappointing, to put it mildly. The USB API implementations out there are pathetic. If you really want to interface with and control hardware that doesn't come with a vendor provided API, I'd have to recommend C#, despite the fact that you are stuck on Windoze. The reality is that it's better to have an API that works on one platform than one that doesn't work at all.
jeeky, maybe youâ€™ve come across a Java program that can read a USB peripheral with switches or knobs? Most of the sources that Iâ€™ve read confirm what you are saying â€“ that, at the present level of development, Java does not have a lot of support for peripherals. However, I am just looking for one Java program that I can modify to give me access to different outputs on my USB development board. That way, I can use the variables - in a premade program that I am hoping someone will refer me, while creating many different programs for my peripheral. For example, is there a program that replaces the cursor - that Windows shows to identify the location of a mouse, with a picture that is specific to this program? If so, does this program enumerate microchip pins in the mouse? Or, what about a Java program for a game that reads joystick data? Is there anything specific about these types of code that would prevent me from modifying these codes to read my peripheral? I am familiar with some of the USB protocol, so I might be able to interpret any peripheral code that you can refer me to with the page at http://jusb.sourceforge.net/apidoc/usb/core/package-summary.html - which contains information that you are likely already familiar with. If you know of too many codes to list, the simpler ones would be easier for me to use!
As Java's USB implementation sucks(and maybe always will), why not use an ethernet development board instead.
ethernet seems to be the future of connecting random things together and something java can do right now.
Thank you, P3aul. Java is what they are teaching in school at my level - and what I have to learn. So, if by a chance that is odd or favorable, anyone knows of any example public domain program code - for peripherals with potentiometers and/or buttons, that I can search through to try and find variables that were declared and defined by the peripheral, this would still be helpful. The simpler the code, the better. Based on your response, I don't expect anyone to point these variables out to me. However, this would be helpful. And someone at school might be able to point these variables out if the code was provided. I was thinking that this post might belong under Global Education and Learning because it address the needs of students with different learning styles.
Message was edited by: jasonbe
I don't really do much device/peripheral stuff myself, but a couple things jumped to mind:
Sun SPOT: http://www.sunspotworld.com/
I wouldn't expect to see "variables that were declared and defined by the peripheral", but rather something more like event listeners. In other words, you register some code with the peripheral and that code gets called back when an event happens (e.g. button press).
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.