Use a 12 volt solenoid or motor. Connect a 12 volt power adapter to the Arduino board. On the board there is a pin called Vin that will provide the 12 volts directly from the power adapter. Use Vin to power the solenoid / motor.

There will be a lot of current flowing through the solenoid. If the flow keeps on too long, the solenoid will get very hot. The on-time will probably needs to be shorter than a second.

The term duty cycle means the relation between on-time and off-time. Generally the duty cycle has to be less than 50% if the solenoid shall be turned on and off repeatedly.




int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(50); // Solenoid gets hot if pin is HIGH too long
  digitalWrite(ledPin, LOW);


Sign In


Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.