Hi
EDIT: I didnt see your latest post. But even when i declare the variables used in the interrupt-routine as volatile, nothing changes.
I think the time isn't a problem, it takes under 100ms to send the message.
In this new version I only change a variable in the ticker function, and check it in the main() funtion. Now the LEDs work fine, but nothing is send, the ticker routine will never be called.
Arghh.
#include "mbed.h"
void led_dimm_streifen();
PwmOut myled1(LED1);
PwmOut myled2(LED2);
PwmOut myled3(LED3);
PwmOut myled4(LED4);
AnalogIn ain(p20);
AnalogIn ain2(p19);
Ticker ticktack;
float p;
float leds;
volatile int flag=1;
void info_ticker() {
//leds=ain.read();
//p=ain2.read();
flag=1;
}
int main() {
ticktack.attach(&info_ticker, 2.0);
leds=ain.read();
p=ain2.read();
if (flag==1) {
printf("LED: %f PWM: %f \r\n",leds, p);
//printf("LED: %f PWM: %f \r\n",ain.read(), ain2.read());
flag=0;
} else {}
while (1) {
led_dimm_streifen();
}
}
void led_dimm_streifen() {
p=ain2.read();
myled1 = (ain > 0.2) ? p : 0;
myled2 = (ain > 0.4) ? p : 0;
myled3 = (ain > 0.6) ? p : 0;
myled4 = (ain > 0.8) ? p : 0;
}
Hello
My problem is that the ticker prevents my programm from working. Before the ticker ticks for the first time(first three seconds) everything works fine. But when the ticker ticks the first time, only the messages are send and nothing else works.
Any idears?