Télécharger Imprimer la page

Raspberry PICO Mode D'emploi page 90

Publicité

Modification du fichier « thermometre.c »
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/adc.h"
int
main() {
stdio_init_all();
printf("ADC Example, measuring
adc_init();
// Select ADC input 4 thermometre
adc_select_input(4);
while
(1) {
// 12-bit conversion, assume max value == ADC_VREF == 3.3 V
uint16_t
result
printf("Thempérature: %f
sleep_ms(500);
}
}
Modification du fichier « CMakeLists.txt » du répertoire « adc » afin d'y ajouter le programme
« thermometre »
if
(NOT
PICO_NO_HARDWARE)
add_subdirectory(adc_console)
add_subdirectory(dma_capture)
add_subdirectory(hello_adc)
add_subdirectory(joystick_display)
add_subdirectory(microphone_adc)
add_subdirectory(thermometre)
endif
()
Puis compilation de tous les exemples par les commandes « cmake et make –j4 »
Le programme se trouve dans le répertoire « build/adc/thermometre »
GPIO26\n");
=
(27
- (adc_read() *
°\n", result);
(3.3f
/ (65535)) - 0.706f) / 0.001721f);

Publicité

loading

Ce manuel est également adapté pour:

Pico w