Hi Atamert, Thanks for your response. I get the "looping" message and then it just sits there. This is what I see in my console:
pi@raspberrypi /opt/pi4j/examples $ runclojure clojure/examples.clj Start running blinkio hello looping Then it just sits there. After a certain amount of time, it ends and returns back to the prompt. I am running clojure 1.6.0 On Friday, June 13, 2014 12:33:24 AM UTC-4, Andre Perez wrote: > > Hi everyone, I just started trying to play with a raspberry pi for a > variety of reasons, and given that java runs on it, I decided to use this > as an opportunity to learn clojure. I'm playing with a blinkIo example > which looks like this: > > public class BlinkGpioExample { > > > public static void main(String[] args) throws InterruptedException { > > > System.out.println("<--Pi4J--> GPIO Blink Example ... started."); > > > // create gpio controller > > final GpioController gpio = GpioFactory.getInstance(); > > > // provision gpio pin #01 & #03 as an output pins and blink > > final GpioPinDigitalOutput resevoirPumpLine = gpio > > .provisionDigitalOutputPin(RaspiPin.GPIO_01); > > final GpioPinDigitalOutput troughFillLine = gpio > > .provisionDigitalOutputPin(RaspiPin.GPIO_03); > > > // provision gpio pin #02 as an input pin with its internal pull down > > // resistor enabled > > final GpioPinDigitalInput resevoirSwitch = gpio.provisionDigitalInputPin( > > RaspiPin.GPIO_14, "Resevoir Switch", PinPullResistance.PULL_DOWN); > > final GpioPinDigitalInput trougSwitch = gpio.provisionDigitalInputPin( > > RaspiPin.GPIO_13, "Trough Switch", PinPullResistance.PULL_DOWN); > > resevoirSwitch.setShutdownOptions(true); > > // create and register gpio pin listener > > resevoirSwitch.addListener(new GpioPinListenerDigital() { > > @Override > > public void handleGpioPinDigitalStateChangeEvent( > > GpioPinDigitalStateChangeEvent event) { > > // when button is pressed, speed up the blink rate on LED #2 > > if (event.getState().isHigh()) { > > System.out.println(event.getPin().getName() + " do nothing"); > > } else { > > resevoirPumpLine.blink(1000); > > } > > } > > }); > > > trougSwitch.addListener(new GpioPinListenerDigital() { > > > @Override > > public void handleGpioPinDigitalStateChangeEvent( > > GpioPinDigitalStateChangeEvent event) { > > if (event.getState().isHigh()) { > > System.out.println(event.getPin().getName() + " do nothing"); > > } else { > > //stick value into a flat file or in mem database; > > troughFillLine.blink(1000); > > } > > > } > > }); > > > System.out > > .println(" ... the LED will continue blinking until the program is > terminated."); > > System.out.println(" ... PRESS <CTRL-C> TO STOP THE PROGRAM."); > > > // keep program running until user aborts (CTRL-C) > > for (;;) { > > Thread.sleep(500); > > } > > > } > > } > > > > Since I am quite new to clojure, i attempted to do a straight port to > clojure (as opposed to writing the blinkio in a more functional manner) and > came up with : > > (def factory (GpioFactory/getInstance) ) > > > (def pumpOutput (.provisionDigitalOutputPin factory RaspiPin/GPIO_01)) > > (def troughOutput (.provisionDigitalOutputPin factory RaspiPin/GPIO_03)) > > > > (def pumpInput (.provisionDigitalInputPin factory RaspiPin/GPIO_13 > "troughSwitch" PinPullResistance/PULL_DOWN)) > > (def resevoirInput (.provisionDigitalInputPin factory RaspiPin/GPIO_14 > "resevoirSwitch" PinPullResistance/PULL_DOWN)) > > > > (def resevoirListener (reify > com.pi4j.io.gpio.event.GpioPinListenerDigital ( > handleGpioPinDigitalStateChangeEvent [this event] (printf "resevoir here") > ))) > > (.addListener resevoirInput [ > ^com.pi4j.io.gpio.event.GpioPinListenerDigital resevoirListener] ) > > > (def troughListener (reify com.pi4j.io.gpio.event.GpioPinListenerDigital ( > handleGpioPinDigitalStateChangeEvent [this event] (printf "trough here"))) > ) > > (.addListener resevoirInput [ > ^com.pi4j.io.gpio.event.GpioPinListenerDigital troughListener] ) > > > (defn infinite [f seconds] (future (loop [] (f) ( > Thread/sleep (* seconds 1000)) (recur)))) > > > (infinite (printf "\nlooping") 10) > > > ********** > > My question: This compiles, and runs, but doesn't actually do anything > when I manipulate the PI io. I am thinking I have to do something > regarding defining my inputIOs as atoms, but I'm still trying to get my > head wrapped around that concept. Could someone please point me in the > right direction to get my (printf "trough /resevoir here") messages to > display? Mind you that there isn't a problem with any of the wiring on the > PI, it is verified in the java version of this program. I am just having > trouble porting this code. > > > Thanks for any help! > > Andre > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.