锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

Arduino UNO输出高电平点亮LED(三)

时间:2022-09-05 04:00:00 热过载继电器lrd06c热继电器lrd1321n10

通过 Arduino UNO输出高电平点亮LED。
注意LED最大承载电压约为2V,10ma~15ma,需要串联一个电阻100R-200R左右都可以。一端连接。GND或者,一端连接输出端子。
/*
Input Pull-up Serial

This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a digital
input on pin 2 and prints the results to the Serial Monitor.

The circuit:

  • momentary switch attached from pin 2 to ground
  • built-in LED on pin 13

Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal
20K-ohm resistor is pulled to 5V. This configuration causes the input to read
HIGH when the switch is open, and LOW when it is closed.

created 14 Mar 2012
by Scott Fitzgerald

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/InputPullupSerial
*/

void setup() {
//start serial connection
Serial.begin(115200);
//configure pin 2 as an input and enable the internal pull-up resistor
//pinMode(2, INPUT_PULLUP);
pinMode(8, OUTPUT);

}

void loop() {
//read the pushbutton value into a variable
//int sensorVal = digitalRead(2);
//print out the value of the pushbutton
//Serial.println(sensorVal);

// Keep in mind the pull-up means the pushbutton’s logic is inverted. It goes
// HIGH when it’s open, and LOW when it’s pressed. Turn on pin 13 when the
// button’s pressed, and off when it’s not:
//if (sensorVal == HIGH) {
// digitalWrite(13, LOW);
//} else {
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
delay(500);
//}
}

锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章