upm  0.2.0
Sensor/Actuator repository for libmraa (v0.6.1)
Public Member Functions

C++ API for the Grove Electromagnet. More...

Detailed Description

The Grove Electromagnet can hold up to 1 KG (approximately 2.2 lbs)

// The was tested with the Grove Electromagnetic Module
// Instantiate a Grove Electromagnet on digital pin D2
cout << "Starting up magnet...." << endl;
magnet->off();
bool magnetState = false;
float time_passed = get_time();
// Turn magnet on and off every 5 seconds
while (shouldRun)
{
if ((get_time() - time_passed) > 5.0)
{
magnetState = !magnetState;
if (magnetState)
magnet->on();
else
magnet->off();
cout << "Turning magnet " << ((magnetState) ? "on" : "off") << endl;
time_passed = get_time();
}
}

Public Member Functions

 GroveElectromagnet (int pin)
 
 ~GroveElectromagnet ()
 
void on ()
 
void off ()
 

Constructor & Destructor Documentation

GroveElectromagnet ( int  pin)

Grove Electromagnet Constructor

Parameters
pindigital pin to use

Grove Electromagnet Destructor

Member Function Documentation

void on ( )

Turn magnet on

void off ( )

Turn magnet off


The documentation for this class was generated from the following files: