Jump to content


Photo

Help creating Access to GPIO from Java


  • Please log in to reply
4 replies to this topic

#1 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 09:45 PM

Hello --
I am excited about pcDuino's potential for supporting computer programming learning that bridges between traditional CS and physcal computing.
My first interest is to connect the modeling and programming environment NetLogo to the gpio pins -- so that what i do now using computer + arduino can be done all from pcDuino.
What is the best way to create access to GPIO from a Java application? 
When I get this started I will post notice of the github repository --> it looks like some people are interested in using Processing, and I bet the same approach will work with minor modifications.
Thanks!



#2 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 09:45 PM

 don't do any Java, but just open the files in /sys/devices/virtual/misc/gpio/mode/ and /sys/devices/virtual/misc/gpio/pin/, then set the pin direction in the "mode" file, then read or write the values from the "pin" file.

Have a look on the Wiki at http://www.pcduino.c...in_usage_from_C to see it done in C.
 


#3 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 09:45 PM

Thanks!  You're right -- linux's treatment of devices as files made this VERY easy to do.
I've got a first version (so far just digitalwrite) up and running now on github at
https://github.com/c...yatinquire/gpio

thanks again,
-c



#4 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 09:45 PM

cool.  extension now supports digital read, digital write, analog read, and pwm write (pwm isn't tested yet). thanks



#5 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 09:45 PM

Just posted this: http://pcduino.com/f...msg4784#msg4784

All in Java! And the source code is available as well smiley.gif






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users