This site requires JavaScript, please enable it in your browser!
Greenfoot back
cstallworth
cstallworth wrote ...

2012/4/18

Greenfoot talking with an Arduino

cstallworth cstallworth

2012/4/18

#
My goal is to get Greenfoot to have two way communication with an Arduino. I have downloaded the scenarios and used a PicoBoard with Greenfoot. My thought was that I could learn how the serial communication was done and imitate that for serial communication with the Arduino. Alas, the picolib class and the RXTXcomm class are only provided in .jar form. Does anyone have any suggestions?
sp33dy sp33dy

2012/4/18

#
I could be very wrong, but could you drop the .jar in the Greenfoot installation directory/lib to see if you can then import the classes you need?
sp33dy sp33dy

2012/4/18

#
actually, there is a lib/userlib directory with a nice readme.txt!!! I guess you stick it here.
davmac davmac

2012/4/18

#
The picolib.jar file contains source code (just extract the file contents). The RXTXcomm.jar file is part of the RXTX library, which is open source - just google it.
mjrb4 mjrb4

2012/4/18

#
I've actually done the bulk of this already - I have a few demo scenarios working with a Mega sitting on my desk, one that uses a potentiometer and a button to control a breakout game. I should really polish it up and put it up on the site at some point... Until then, I've thrown the examples up along with a brief explanation at http://www.greenfoot.org/static/Arduino.zip. Let me know if you have any problems, and remember you may need to modify the pin numbers used in code depending on what Arduino you're using and where you've hooked the circuitry up.
cstallworth cstallworth

2012/4/19

#
Wow, all of you have been most helpful. I am going to move forward with your suggestions and report back on my progress. Much thanks
LuigiChi LuigiChi

2014/9/30

#
Hi, is there some news on connecting Greenfoot and Arduino? Thanks!
davmac davmac

2014/9/30

#
Does mjrb4's example not work for you?
LuigiChi LuigiChi

2014/9/30

#
Thanks, Davmac. When I play Run, it appears an error message beginning with "java.lang.UnsatisfiedLinkError: C:\Users\Lu\Documents\ArduinoAppoggio\GreenfootArduino\Arduino\Greenfoot_Arduino\Arduino demo LED\native\Windows\rxtxSerial.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform thrown while loading gnu.io.RXTXCommDriver java.lang.UnsatisfiedLinkError: C:\Users\Lu\Documents\ArduinoAppoggio\GreenfootArduino\Arduino\Greenfoot_Arduino\Arduino demo LED\native\Windows\rxtxSerial.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform" I think that my RxTx libraries are not correctly installed (Windows 7 Pro, 64 bit). Is it necessary to download some new version of these libraries? Where it should be placed? Thanks! Luigi
davmac davmac

2014/9/30

#
The RxTx libraries are included in mjrb4's zip bundle, in the right place. It looks like for some reason the system is trying to load the 32-bit version of the library instead of (or as well as) the 64-bit version. Maybe you should just remove the 32-bit version from your project (the version in "native\Windows").
LuigiChi LuigiChi

2014/9/30

#
We need to uncomment the correct line in the NativePathSetter class. With s+= "native/Windows64;"; its all ok, when the ball touch the house the LED on Pin 13 ligths Thank You very much!!!
You need to login to post a reply.