Skip to content
Snippets Groups Projects
Commit 8f4000da authored by ma1u20's avatar ma1u20
Browse files

Replace pushButton.c

parent 1f6d3de4
No related branches found
No related tags found
No related merge requests found
......@@ -8,23 +8,23 @@ bool getLogicState() {
}
int main() {
// Initialize LED pin as output
gpio_init(ledPin);
gpio_set_dir(ledPin, GPIO_OUT);
// Initialize push button pin as input
gpio_init(pushButtonPin);
gpio_set_dir(pushButtonPin, GPIO_IN);
gpio_pull_up(pushButtonPin);
while (true) {
bool logicState = getLogicState();
if (logicState) { // If push button pressed
if (logicState) {
gpio_put(ledPin, 1); // Turn LED on
} else { // If push button not pressed
} else {
gpio_put(ledPin, 0); // Turn LED off
}
sleep_ms(10); // Delay to avoid debounce issues
sleep_ms(10);
}
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment