Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 1 month ago.
Having some issues with declaring variables
I know that there has to be a way to declare variables, I just have not figured them out or I am doing them wrong. I am used to declaring variables the arduino IDE way, how do I do them with them KL25z? I am looking to have some global variables that I can write analog in values to and do some math to get what I want out of them. So if I can be pointed in the right direction I would be very happy indeed. I do love this little thing, just have to learn its quirks. My next project is going to be connecting this to the electric imp.
1 Answer
11 years, 1 month ago.
It works pretty much the same as in Arduino. If you want to have a global variable you should define them outside of any functions, at the top of your code.
So something like:
#include "mbed.h" DigitalOut led(LED_RED); //This is in principle also a global variable int global_int; void myfunction( void ) { } int main() { }