Button LibraryThe Button Library provides routines for detecting butto dịch - Button LibraryThe Button Library provides routines for detecting butto Việt làm thế nào để nói

Button LibraryThe Button Library pr

Button Library
The Button Library provides routines for detecting button presses and debouncing (eliminating the influence of contact flickering upon pressing a button).
Library Routines
Button
Button
Prototype
unsigned short Button(unsigned short *port, unsigned short pin, unsigned short time, unsigned short active_state);

Returns
255 if the pin was in the active state for given period.
0 otherwise

Description
Function eliminates the influence of contact flickering upon pressing a button (debouncing).
Parameter port specifies the location of the button; parameter pin is the pin number on designated port and goes from 0..7; parameter time is a debounce period in milliseconds; parameter active_state can be either 0 or 1, and it determines if the button is active upon logical zero or logical one.

Requires
Button pin must be configured as input.

Example
Example reads RB0, to which the button is connected; on transition from 1 to 0 (release of button), PORTD is inverted:
bit oldstate; // Old state flag

void main() {

ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;

TRISB0_bit = 1; // set RB0 pin as input

TRISC = 0x00; // Configure PORTC as output
PORTC = 0xAA; // Initial PORTC value
oldstate = 0;

do {
if (Button(&PORTB, 0, 1, 1)) { // Detect logical one
oldstate = 1; // Update flag
}
if (oldstate && Button(&PORTB, 0, 1, 0)) { // Detect one-to-zero transition
PORTC = ~PORTC; // Invert PORTC
oldstate = 0; // Update flag
}
} while(1); // Endless loop
}

0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Button LibraryThe Button Library provides routines for detecting button presses and debouncing (eliminating the influence of contact flickering upon pressing a button).Library RoutinesButton ButtonPrototypeunsigned short Button(unsigned short *port, unsigned short pin, unsigned short time, unsigned short active_state);Returns255 if the pin was in the active state for given period. 0 otherwise DescriptionFunction eliminates the influence of contact flickering upon pressing a button (debouncing).Parameter port specifies the location of the button; parameter pin is the pin number on designated port and goes from 0..7; parameter time is a debounce period in milliseconds; parameter active_state can be either 0 or 1, and it determines if the button is active upon logical zero or logical one.RequiresButton pin must be configured as input.ExampleExample reads RB0, to which the button is connected; on transition from 1 to 0 (release of button), PORTD is inverted:bit oldstate; // Old state flagvoid main() { ANSEL = 0; // Configure AN pins as digital I/O ANSELH = 0; C1ON_bit = 0; // Disable comparators C2ON_bit = 0; TRISB0_bit = 1; // set RB0 pin as input TRISC = 0x00; // Configure PORTC as output PORTC = 0xAA; // Initial PORTC value oldstate = 0; do { if (Button(&PORTB, 0, 1, 1)) { // Detect logical one oldstate = 1; // Update flag } if (oldstate && Button(&PORTB, 0, 1, 0)) { // Detect one-to-zero transition PORTC = ~PORTC; // Invert PORTC
oldstate = 0; // Update flag
}
} while(1); // Endless loop
}

đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Nút Thư viện
Các nút Thư viện cung cấp các thói quen để phát hiện nút bấm và debouncing (loại trừ ảnh hưởng của xúc chập chờn khi nhấn một nút).
Thư viện thói quen
nút
nút
Prototype
unsigned nút ngắn (unsigned ngắn * cổng, pin ngắn không dấu, thời gian ngắn không dấu, unsigned ngắn active_state); Trả 255 nếu pin đã ở trong trạng thái hoạt động cho thời gian nhất định. 0 nếu ngược Mô tả Chức năng loại bỏ ảnh hưởng của xúc chập chờn khi nhấn một nút (debouncing). cổng thông số xác định vị trí của các nút; pin tham số là số pin trên cổng được chỉ định và đi từ 0..7; thời gian tham số là một khoảng thời gian trễ trong mili giây; . active_state tham số có thể là 0 hoặc 1, và nó quyết định nếu nút là hoạt động khi có một logic không hay hợp lý Yêu cầu Nút pin phải được cấu hình như là đầu vào. Ví dụ Ví dụ đọc RB0, mà các nút được kết nối; về quá trình chuyển đổi 1-0 (phát hành nút), PORTD được đảo ngược: bit oldstate; // Old trạng cờ void main () {ANSEL = 0; // Cấu hình AN chân như kỹ thuật số I / O ANSELH = 0; C1ON_bit = 0; // Vô hiệu hoá bộ so sánh C2ON_bit = 0; TRISB0_bit = 1; // Thiết lập RB0 pin như đầu vào TRISC = 0x00; // Cấu hình PORTC là đầu ra PORTC = 0xAA; // Giá trị ban đầu PORTC oldstate = 0; do {if (Button (& PORTB, 0, 1, 1)) {// Phát hiện logic một oldstate = 1; // Cập nhật cờ} if (oldstate && Button (& PORTB, 0, 1, 0)) {// Phát hiện một-không chuyển PORTC = ~ PORTC; // Invert PORTC oldstate = 0; // Cập nhật cờ}} while (1); // Endless vòng lặp}








































đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2025 I Love Translation. All reserved.

E-mail: