Analog Input #264
Replies: 1 comment 13 replies
-
HI, and thanks for the kind words on the stem drone tutorial. We're happy you found it useful! I'll start with your question 3: The simple answer is that you use python for code that run in the PC and C for code that runs in the Crazyflie. In this case you will have to write some code in C to make the Crazyflie read your analog input. I guess that you maybe also want to use the analog value in your PC and to make this work you will have to write some code in the Crazyflie (C) that "publishes" the data and some python code for the PC that reads the values from the Crazyflie an does something useful with it, like printing or graphing the value. Question 1: One way to look at header files (in general) is that they describe other parts of the code, for instance the signature of a function or, as in this case some constants that can be used in a function. Question 2: You include the header files at the top of a .c file and then use the functions and constants in your code. Something like this: #include "deck_constants.h"
#include "deck_analog.h""
float readMyAnalogPin() {
return analogReadVoltage(DECK_GPIO_MISO);
} Check the Expansion port pinout to figure out which pin constant to use. In the example above
|
Beta Was this translation helpful? Give feedback.
-
Hello. I would like to measure the voltage of an external sensor using an analog input. I have the prototype deck. (And also the flow deck and CrazyRadio, FYI.) I understand there are analog input channels A0 thru A4, and ground.
If I digress for the moment, I'd like to say that I love this tutorial: https://www.bitcraze.io/documentation/tutorials/getting-started-with-stem-drone-bundle/, because I more or less understand all the code. I ran it successfully.
Back to analog input, I found this post: https://forum.bitcraze.io/viewtopic.php?t=2908. It seems like I need the two *.h files, deck_analog.h and deck_constants.h. That's understood, but...
Thanks for the help!
Beta Was this translation helpful? Give feedback.
All reactions