Electromagnet Superhero Glove

Step 10: Program Arduino.

Picture of Program Arduino.
Select the right COM port. My board is a Lilypad ATmega 328.

Here is the code:

const int finger = 8;
const int palm = 5;
const int button = 13;
const int empin = 10;
int buttonstate = 0;
int sensorstate = 0;

void setup() {
  pinMode(button, INPUT);
  pinMode(finger, OUTPUT);
  pinMode(palm, INPUT);
  pinMode(empin, OUTPUT);


void loop() {
  digitalWrite(palm, HIGH);
  buttonstate = digitalRead(button);
  sensorstate = digitalRead(finger);
  if (buttonstate == HIGH){
    if (sensorstate == LOW){
      digitalWrite(empin, HIGH);
    digitalWrite(empin, LOW);

Remove these adsRemove these ads by Signing Up

Get More Out of Instructables

Already have an Account?


PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!