

location_on 4131 Fraser St. Vancouver BC Get Directions
phone 604-875-1993 Call us
access_time Hours
Monday - Friday | 9AM - 5:30PM |
Saturday - Sunday & Holidays | Closed | See Holiday Hours |
This item has been retired.
An electromagnet is a type of magnet in which the magnetic field is produced by electric current. An electric current flowing in a wire creates a magnetic field around the wire, due to Ampere's law(see drawing below). To concentrate the magnetic field, in an electromagnet the wire is wound into a coil with many turns of wire lying side by side. The magnetic field of all the turns of wire passes through the center of the coil, creating a strong magnetic field there. Grove - Electromagnet can suck 1KG weight and hold on. It is easy to use, to learn electromagnet principle.
Item | Value |
---|---|
Working Voltage | DC 5V |
Working Current | 400mA |
Standby Current | 200uA |
Load Weight | 1KG |
Arduino | Raspberry Pi | BeagleBone | Wio | LinkIt ONE |
---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
Caution
The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.
Note
If this is the first time you work with Arduino, we firmly recommend you to see Getting Started with Arduinobefore the start.
Hardware
Seeeduino V4.2 | Base Shield | Grove-Electromagnet |
---|---|---|
![]() |
![]() |
![]() |
Note
If we don't have Grove Base Shield, We also can directly connect Grove-Electromagnet to Seeeduino as below.
Seeeduino | Grove-Ultrasonic Ranger |
---|---|
5V | Red |
GND | Black |
Not Conencted | White |
D2 | Yellow |
Software
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
/* Turns on an Electromagnet on for one second, then off for one second, repeatedly. This example code is in the public domain. */ int Electromagnet = 0; int LED = 13; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(Electromagnet, OUTPUT); pinMode(LED, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(Electromagnet, HIGH); // turn the Electromagnet on (HIGH is the voltage level) digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(Electromagnet, LOW); // turn the Electromagnet off by making the voltage LOW digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } |
Hardware
Raspberry pi | GrovePi_Plus | Grove-Electromagnet |
---|---|---|
![]() |
![]() |
![]() |
Get One Now | Get One Now | Get One Now |
Step 2. Plug the GrovePi_Plus into Raspberry.
Step 3. Connect Grove-Electromagnet to D4 port of GrovePi_Plus.
Step 4. Connect the Raspberry to PC through USB cable.
Software
Step 1. Follow Setting Software to configure the development environment.
Step 2. Follow Updating the Firmware to update the newest firmware of GrovePi.
Tip
In this wiki we use the path ~/GrovePi/ instead of /home/pi/Desktop/GrovePi, you need to make sure Step 2 and Step 3 use the same path.
Note
We firmly suggest you to update the firmware, or for some sensors you may get errors.
1 2 |
cd ~ git clone https://github.com/DexterInd/GrovePi.git |
1 |
cd yourpath/GrovePi/Software/Python/ |
Here is the grove_electromagnet.py code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import time import grovepi # The electromagnet can hold a 1KG weight # Connect the Grove Electromagnet to digital port D4 # SIG,NC,VCC,GND electromagnet = 4 grovepi.pinMode(electromagnet,"OUTPUT") time.sleep(1) while True: try: # Switch on electromagnet grovepi.digitalWrite(electromagnet,1) print "on" time.sleep(2) # Switch off electromagnet grovepi.digitalWrite(electromagnet,0) print "off" time.sleep(2) except KeyboardInterrupt: grovepi.digitalWrite(electromagnet,0) break except IOError: print "Error" |
5.Run the demo.
1 |
sudo python grove_electromagnet.py |