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.
7 years ago.
Can you spot the mistake ?
I not able to run the following code, can anyone spot the mistake ... The error says "Error: Expression must have class type "a.start(sample);" I am using NUCLEO F767ZI board
1 Answer
7 years ago.
Your thread, sample() has argument.
You can pass the argument using callback.
// Run on Nucleo-F411RE #include "mbed.h" DigitalOut led1(LED1); DigitalOut led2(D7); DigitalOut led3(D6); Thread a; void sample(int num[]){ while(true){ if (num[0] == 1){ led1 = 1; led2 = 0; } else if (num[0] == 0){ led1 = 0; led2 = 1; } Thread::wait(10); } } int main(){ int num[4] = {1,0,0,0}; a.start(callback(sample, num)); while (true){ led3 = !led3; if (num[0] == 1){ num[0] = 0; } else { num[0] = 1; } Thread::wait(1000); } }
thanks fr response.I tried the change even then I got the same error.Did your program compile without any error?
posted by 09 Dec 2017