Skip to content
Snippets Groups Projects
Select Git revision
  • 2867a88355dc3cf8107f1e39dd9c9d5151da1e39
  • main default protected
2 results

buttons.c

Blame
  • buttons.c 433 B
    #include "pico/stdlib.h"
    
    int main() {
    	//const uint buttonOne = ?;
    	const uint ledOne = 0;
    	const uint button = 20;
    
    	//gpio_init(buttonOne);
    	gpio_init(ledOne);
    	gpio_init(button);
    
    	//gpio_set_dir(buttonOne, ?);
    	gpio_set_dir(ledOne, GPIO_OUT);
    	gpio_set_dir(button, GPIO_IN);
    
    	//Write your own code to turn a LED on when button is pressed
    	if (!gpio_get(button)) {
    		gpio_put(LED_PIN, 1);
    	}
    	else {
    		gpio_put(LED_PIN, 0);
    	}
    }