First commit and Init

This commit is contained in:
2026-03-23 18:05:52 +01:00
commit ef74514a1c
7 changed files with 83 additions and 0 deletions

25
mein_projekt/main.cpp Normal file
View File

@@ -0,0 +1,25 @@
#include "hardware/i2c.h"
#include "pico/stdlib.h"
#include <cstdio>
void check_i2c() {
uint8_t buffer;
for (int addr{0x08}; addr < 0x78; addr++) {
if (i2c_read_blocking(i2c0, addr, &buffer, 1, false) > 0) {
printf("Adresse: %02X\n", addr);
}
}
}
int main() {
sleep_ms(3000);
stdio_init_all();
i2c_init(i2c0, 400 * 1000);
gpio_set_function(0, GPIO_FUNC_I2C); // SDA
gpio_set_function(1, GPIO_FUNC_I2C); // SCL
gpio_pull_up(0);
gpio_pull_up(1);
while (true) {
check_i2c();
}
}