add blinky and more setup details

This commit is contained in:
2024-02-21 20:34:11 +05:30
parent 761e39cc97
commit f73fb95733
3 changed files with 52 additions and 3 deletions

View File

@@ -2,7 +2,7 @@
### Dev Envitonment ### Dev Envitonment
Nobara 39 on a hand-me-down dual core dell laptop. An RPi Pico, programming over usb cable. Some wires, buttons, LEDs and resistors I <b>Borrowed</b> from lab. Nobara/Fedora 39 on a hand-me-down dual core dell laptop. An RPi Pico, programming over usb cable. Some wires, buttons, LEDs and resistors I <b>Borrowed</b> from lab.
### Code Editor ### Code Editor
Instead of using Arduino IDE, I use Visual Studio Code for programming. I use it because I (seem to) write code more efficiently and because I have it customized it to my liking. Instead of using Arduino IDE, I use Visual Studio Code for programming. I use it because I (seem to) write code more efficiently and because I have it customized it to my liking.
@@ -15,7 +15,7 @@ Extensions I use:
### Project Generation ### Project Generation
A C Pico project requires additional files to handle compilation: CMakeList.txt and pico_sdk_import.cmake, templates of both available in the installed pico sdk. To automate this, I use [Pico Project Generator](https://github.com/raspberrypi/pico-project-generator). A C Pico project requires additional files to handle compilation: CMakeList.txt and pico_sdk_import.cmake, templates of both available in the installed pico sdk. To automate this, I am using [Pico Project Generator](https://github.com/raspberrypi/pico-project-generator) to generate the boilerplate code for the project. Most of the options are left default. The only changes are: `Console over USB` and `Create VSCode Project` are enabled.
<img src="../assets/picoProjGen.png" width="300"> <img src="../assets/picoProjGen.png" width="300">
@@ -40,7 +40,6 @@ So uploading the code requires following steps:
This will mount the pico as a storage device, to where the generated `.UF2` file should be copied. This will mount the pico as a storage device, to where the generated `.UF2` file should be copied.
## Hardware Setup ## Hardware Setup
I have the RaspberryPi Pico Non-W variant: without the wireless chip. Soldered male jumper headers and mounted it onto a large breadboard. I am using solid copper wires for connections, because they stay in set shape. I have the RaspberryPi Pico Non-W variant: without the wireless chip. Soldered male jumper headers and mounted it onto a large breadboard. I am using solid copper wires for connections, because they stay in set shape.

50
1_Basic_GPIO/blinky.md Normal file
View File

@@ -0,0 +1,50 @@
## Blinky
The classic, the helloWorld of embedded programming. This program turns the LED on and off periodically.
### Initial steps:
- Create new project with project generator.
- Open the project folder in VSCode.
- Build the project by pressing the `build` button at the bottom and select the option with `arm-none-eabi`.
- Make sure the build exits with code 0.
<img src="../assets/buildButton.png" width="300">
### Basic Code:
``` C
int main()
{
stdio_init_all();
const uint OnBoardLED = PICO_DEFAULT_LED_PIN;
gpio_init(OnBoardLED);
gpio_set_dir(OnBoardLED, GPIO_OUT);
while (true){
gpio_put(OnBoardLED, true);
sleep_ms(500);
gpio_put(OnBoardLED, false);
sleep_ms(500);
}
}
```
#### Explanation:
`stdio_init_all()`: initialize stuff
`OnBoardLED = PICO_DEFAULT_LED_PIN`: Get the GPIO number of onboard LED. Remember this is GPIO Number, NOT PIN NUMBER.
`gpio_init(OnBoardLED)`: Initialize that GPIO pin.
`gpio_set_dir(OnBoardLED, GPIO_OUT)`: Set GPIO direction (`GPIO_OUT` for writing and `GPIO_IN` for reading).
`while (true){}`: Super loop of the program
`gpio_put(OnBoardLED, true)`: Set `OnBoardLED` pin to `on` (`true` to turn on/set to high/voltage to VDD, `false` to turn off/set to low/voltage to GND)
Pico login HIGH voltage is 3.3v and LOW voltage is 0v.
`sleep_ms(500)`: sleep for 500ms.
---

BIN
assets/buildButton.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB