Friday, May 22, 2015

JAVA Mix sensors with Raspberry Pi

Hello there,

RGB sufrace LED
Here it is the review for next lessons of "Sunfounder 37 modules Sensor Kit for Raspberry Pi Model B". The set of lessons from #02 to #09 are quite easy to code and play with. Just connecting the sensors to the pins 0 or 1 and to GND and 3.3V. No big deal on the hardware side.

shock sensor with RG LED
The software is simple and based on the same concepts from the previous kit "Sunfounder Raspberry Pi Super Kit". Thus the translation from C to JAVA was easy. I just abstracted a new class RGB_BASE with the duplicated code dealing with softPWM for the RGB functions. This class allows to set colours with two or three channels, RGB or RG.

The Ex04_RGB and Ex05_DoubleColorLed extend this RGB_BASE class and simply implement the code to send PWM outputs with different colour frequencies.
Knock sensor with RG LED

From Ex06_ShockSwitch up to Ex10_MagicRing the code also easy. All working fine as expected, but still fun to play and experiment with the sensors. The Ex29_IrRecv for lesson 09 is also easy to code, however it looks like the exercise number and lesson number are a bit mix max from this lesson.

Laser module
Below there are some videos and photos about my experimentation with these sensors. The interesting one was maybe the Infra-red sensor where I needed to use the front camera of my phone in order to see if the sensor was working. The quality of the video is poor though. The reason is that the back camera of the phone has an infra-red filter in order to improve the resolution, so the infra-red light is not capture by normal high quality cameras.

That is all for now, I hope you like it. 
Thanks for reading.
Keep on hacking.

Mini reed switch


RGB with milk bottle as light diffuser.




RG with milk bottle as light diffuser.



Shock sensor



Knock sensor



Infra-red sensor transmitter



Laser module



Reed switch activated by magnetic field variations.

For full details about how to set up your Raspberry Pi and how to run these exercises please check out my old post Raspberri Pi with Pi4j and Junit testing mockups. Or leave me a comment if you have any issue or question.

Posted by Marc Andreu.

No comments: