ist/enlighterjs.min Arduino Digital INPUT and OUTPUT
Type Here to Get Search Results !

Arduino Digital INPUT and OUTPUT

Example Code


Sets pin 2 to the same value as pin 3, declared as an input.

int ledPin = 2;  // LED connected to digital pin 13
int inPin = 3;    // pushbutton connected to digital pin 7
int val = 0;      // variable to store the read value

void setup() {
  pinMode(ledPin, OUTPUT);  // sets the digital pin 13 as output
  pinMode(inPin, INPUT);    // sets the digital pin 7 as input
}

void loop() {
  val = digitalRead(inPin);   // read the input pin
  digitalWrite(ledPin, val);  // sets the LED to the button's value
}






Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.