33
loading...
This website collects cookies to deliver better user experience
/*
* ---------------------------------------
* Copyright (c) Sebastian Günther 2021 |
* |
* [email protected] |
* |
* SPDX-License-Identifier: BSD-3-Clause |
* ---------------------------------------
*/
#include <stdio.h>
#include <stdbool.h>
#include "pico/stdlib.h"
int LED_BUILTIN = 25;
void blink() {
gpio_put(LED_BUILTIN, 1);
sleep_ms(750);
gpio_put(LED_BUILTIN, 0);
sleep_ms(1050);
}
int main() {
stdio_init_all();
gpio_init(LED_BUILTIN);
gpio_set_dir(LED_BUILTIN, GPIO_OUT);
puts("Hello World\n");
while (true) {
puts(".");
blink();
}
}
/*
* ---------------------------------------
* Copyright (c) Sebastian Günther 2021 |
* |
* [email protected] |
* |
* SPDX-License-Identifier: BSD-3-Clause |
* ---------------------------------------
*/
#include <Arduino.h>
int LED_BUILTIN = 25;
void blink() {
digitalWrite(LED_BUILTIN, 1);
delay(750);
digitalWrite(LED_BUILTIN, 0);
delay(1050);
}
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
Serial.write("Hello World\n");
while (true) {
Serial.write(".");
blink();
}
}
lib
folder on the Pico, you can save any scripts, allowing you more complex projects with different files. And if you save a script called main.py
directly in the root directory, this will be executed as your Pico’s program. Alternatively, you can open a serial connection to the Pico and implement a program interactively.#
# ---------------------------------------
# Copyright (c) Sebastian Günther 2021 |
# |
# [email protected] |
# |
# SPDX-License-Identifier: BSD-3-Clause |
# ---------------------------------------
#
from machine import Pin
from utime import sleep
led = Pin(25, Pin.OUT)
while True:
led.toggle()
sleep(1)
#
# ---------------------------------------
# Copyright (c) Sebastian Günther 2021 |
# |
# [email protected] |
# |
# SPDX-License-Identifier: BSD-3-Clause |
# ---------------------------------------
#
import board
import digitalio
from time import sleep
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
sleep(1)
led.value = False
sleep(1)