Skip to content

Add additional C++ Example for AM2302-Sensor #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions gpio/AM2302_sensor/AM2302.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "pico/stdlib.h"
#include "AM2302-Sensor.hpp"

const uint LED = 13U;
const uint LED_PIN = 13U;

// DHT Pin
const uint DHT_PIN = 15;
Expand All @@ -19,10 +19,8 @@ AM2302::AM2302_Sensor am2302{DHT_PIN};
int main() {
stdio_init_all();

#ifdef LED_PIN
gpio_init(LED_PIN);
gpio_set_dir(LED_PIN, GPIO_OUT);
#endif

printf("\n\n === Pi Pico C++ Example - Read AM2302-Sensor === \n\n");
// setup pin and do a sensor check
Expand All @@ -35,14 +33,10 @@ int main() {
sleep_ms(3000);
while (true) {

#ifdef LED_PIN
gpio_put(LED_PIN, 1);
#endif
int8_t status = am2302.read();

#ifdef LED_PIN
gpio_put(LED_PIN, 0);
#endif

printf("Sensor-status: %d\n", status);

Expand All @@ -64,4 +58,4 @@ int main() {
printf("\n\n");
sleep_ms(2000);
}
}
}