GrovePi and electro magnet


#1

Hello!

I’m looking to get into interactive art installations, and since I already own two Pi’s, I thought GrovePi might be a good start into the world of electronics.

A question I have to start: Can the electro magnet be controlled more precisely than turning it on and off every second? (As shown in the example code.) That is, could you run it on a lower voltage, or could you sent an intermittent signal which would result in a smaller net force?

Thanks!


#2

Hi Robert,
You can try using the analogWrite() function to control the voltage to a Port. We have not tried out the electromagnet but I think that it should work.
You can send a value to a Port b/w 0-255, where 0 means 0 Volt and 255 means 5V with the function. So grovepi.analogWrite(PORT,127) means that it will give out 2.5V at the PORT plug, where PORT is the port on the GrovePi. Remember, this works only on Digital Ports 3,5 and 6.
Check this example on how to use analogWrite: https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_led_fade.py .

Let us know if you need any more help and do keep us posted on your project.

-Karan