int ledPin = 13; // LED는 디지털 핀 13에 연결됨
int inPin = 7; // pushbutton은 디지털 핀 7에 연결됨
int val = 0; // 읽은 값을 저장할 변수
void setup() {
pinMode(ledPin, OUTPUT); //디지털 핀 13을 출력으로 설정
pinMode(inPin, INPUT); // 디지털 7을 입력으로 설정
}
void loop() {
val = digitalRead(inPin); // 입력 핀으로부터 읽기
digitalWrite(ledPin, val); // LED 를 버튼의 값으로 설정
}
주의와 경고
핀이 아무데도 연결되지 않으면, digitalRead()은 HIGH나 LOW 중 아무 값이나 임의로 반환할 수 있습니다.
We care about the privacy and personal data of our users.
To continue, please give us your consent:
Please confirm that you have read the privacy policy
Thank you for subscribing!
Curious to learn more?
Are you also a teacher, student, or professional that loves using Arduino in your day-to-day activities?
Then keep up-to-date with either our STEM or Professional monthly newsletters.
Arduino weekly newsletter (already subscribed)
Educators can benefit from the ever growing tech that shapes our environment through fun cool projects.
Why not awe your boss with highly innovative ways to help keep your enterprise connected at no extra cost?
Arduino Survey
We'd like to get to know you little better.
Please help us improve by answering this super short optional survey.