Solenoid
Parts
-Arduino microcontroller and carrier board
-LiPo battery
-Solenoid
-Female-Female extension cable
Prepare the breadboard
Program the Microcontroller
/**
* @file: Solenoid example
* @section DESCRIPTION
* turn solenoid on/off every 2sec
*
*/
// include additional headers
// none
// solenoid should go on the power side!
#define SOLENOID 5 //use female-female extension cable
//--- Function: Setup ()
void setup ()
{
pinMode (SOLENOID, OUTPUT); // enable pin for digital output
}
//--- Function: loop ()
void loop ()
{
digitalWrite (SOLENOID, HIGH); // turn on the solenoid
delay (2000); // wait 2 second (2000 milliseconds)
digitalWrite (SOLENOID, LOW); // turn off the solenoid
delay (2000); // wait 2 seconds
}