top of page


int incomingByte = 0;// for incoming serial data
const int motorPin = 3;

int inPin = 2;   // choose the input pin (for a pushbutton)
int val = 0;     // variable for reading the pin status
void setup()
{  
  Serial.begin(9600);
  pinMode(motorPin, OUTPUT);
  pinMode(inPin, INPUT_PULLUP);    // declare pushbutton as input
}

void loop()
{
  val = digitalRead(inPin);  // read input value
if (val == LOW) {         // check if the input is LOW (button pressed)
    delay(1000);
    digitalWrite(motorPin, HIGH); 
    //Serial.println("HI");
    delay(1000);   
}else{
    digitalWrite(motorPin, LOW);  
    //Serial.println("BYE");
  }  
}

bottom of page