Konfiguruje określony styk, aby zachowywał się jako wejście lub wyjście. Szczegółowe informacje na temat funkcjonalności styków można znaleźć na stronie Styków cyfrowych.
Począwszy od Arduino 1.0.1, możliwe jest włączenie wewnętrznych rezystorów podciągających w trybie INPUT_PULLUP. Dodatkowo tryb INPUT jawnie wyłącza podciągnięcie wewnętrzne.
Składnia
pinMode(styk, tryb)
Parametry
styk: numer styku, którego tryb chcesz ustawić. tryb: INPUT, OUTPUT, lub INPUT_PULLUP. Zobacz stronę Styki cyfrowe, aby uzyskać pełniejszy opis funkcjonalności.
Wartości zwracane
Nic
Przykładowy kod
Ten kod ustawia cyfrowy styk 13 jako wyjście (OUTPUT) i przełącza go w stan wysoki (HIGH) a nastęþnie niski (LOW)
void setup() {
pinMode(13, OUTPUT); // ustawia styk cyfrowy nr 13 jako wyjście
}
void loop() {
digitalWrite(13, HIGH); // ustaw styk cyfrowy nr 13 w stan wysoki
delay(1000); // czekaj jedną sekundę
digitalWrite(13, LOW); // ustaw styk cyfrowy nr 13 w stan niski
delay(1000); // czekaj jedną sekundę
}
Uwagi i ostrzeżenia
Analogowe styki wejściowe mogą być używane jako styki cyfrowe, określane jako A0, A1 itp.
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.