0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Raspberry pi picoで遊んでみる

Last updated at Posted at 2025-12-25

これは「木更津高専 アドベントカレンダー2025」 25日目の記事です。

はじめに

Raspberry pi pico 2 Hの完成品をゲットしました。
折角なのでこれで少し遊びます。

基盤を眺める

Raspberry pi 400やRaspberry pi 3(Model B+)などで遊び倒していた私にとってPico 2 Hはとても小さく感じました。
IMG_3958.jpg

400と並べるとこの通り。
IMG_3960.jpg

完成品だったので裏にピンがついてます。
IMG_3961.jpg

使ってみる

そろそろ使ってみましょう。今回はまあ、Lチカができればよいこととしましょう。

準備

参考書籍によると、デバッグのためにはデバッグプローブという専用の機器が必要になるそうです。
IMG_3962.jpg

こいつのことですね。
こいつを刺してデバッグなどをする様です。
Visual Studio Code 2025_12_24 23_12_06.png

とりあえず本に書いてある通りにセットアップします。
VSCodeに拡張機能あるの良いですね。
聞いた話によるとArduinoIDEでも操作できるとのことですが、とりあえず本の内容通りにPico SDKとやらでやってみます。
Visual Studio Code 2025_12_24 23_12_34.png

おお。これでプロジェクト設定ができる、と。
適当に設定して早速コードを記述します。
今回はAIに書かせました。

#include <stdio.h>
#include "pico/stdlib.h"

int main() {
    stdio_init_all();

    const uint LED_PIN = 4; // GPIO4 に外付けLEDを接続
    gpio_init(LED_PIN);
    gpio_set_dir(LED_PIN, GPIO_OUT);

    while (true) {
        gpio_put(LED_PIN, 1);
        printf("LED ON\n");
        sleep_ms(500);

        gpio_put(LED_PIN, 0);
        printf("LED OFF\n");
        sleep_ms(500);
    }
}

aIMG_3958.jpg

BOOTSELボタン押しながら接続して...
IMG_3984.jpg

...光らん。
first-contact.c - first-contact - Visual Studio Code 2025_12_26 0_11_44.png

ログ見る限り問題なさそうなんだが。
LEDか抵抗の問題っぽい。

ここでやめてもいいのですがさんざん延期した挙句書けませんでしたーなんてなりたくないので
予定変更します。
IMG_3958.jpg

本体のLEDを光らせましょう。

#include <stdio.h>
#include "pico/stdlib.h"

int main() {
    stdio_init_all();

    const uint LED_PIN = PICO_DEFAULT_LED_PIN; // オンボードLED
    gpio_init(LED_PIN);
    gpio_set_dir(LED_PIN, GPIO_OUT);

    while (true) {
        gpio_put(LED_PIN, 1);
        printf("LED ON\n");
        sleep_ms(500);

        gpio_put(LED_PIN, 0);
        printf("LED OFF\n");
        sleep_ms(500);
    }
}

BOOTSEL長押しして接続し書き込み...

PS C:\Users\meron\first-contact> & "$env:USERPROFILE\.pico-sdk\picotool\2.2.0-a4\picotool\picotool.exe" load "c:\Users\meron\first-contact\build\first-contact.uf2" -fx
Family ID 'rp2350-arm-s' can be downloaded in absolute space:
  00000000->02000000
Loading into Flash:   [==============================]  100%

The device was rebooted to start the application.

IMG_3985.jpg

光った!!!

おわりに

さんざん延期した挙句しょぼいものしかお届けできず大変申し訳ございませんでした。
LEDに関してはまあ、正しいものを調達しなかった自分の問題です。
LEDは再調達とかどうかして光らせたいですね。光らせたら追記します。
いやあ、油断は恐ろしい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?