I'm currently working on a project. I'm sending UDP messages from a program on the computer, to a raspberry PI who has a nuclear F303RE microcontroller connected via serial. The microcontroller has one sensor and one led connected. If the sensor voltage drop under a specific value, the led will lighted up. From my program, I send a UDP message to the raspberry PI, who forwards it to the serial port and the microcontroller. Setting the trigger value "d" in the program only works one time. After setting it for the first time, it won't let me set it again. I've been searching around for a day now, but haven't found any solution. Anyone here have an idea ?
#include "mbed.h"
DigitalOut Vcc(PA_0);
AnalogIn aInnA1(PA_1);
DigitalOut Gnd(PA_4);
DigitalOut myled(PA_6);
static float voltage1=0.0f;
void utspenning()
{
float voltage1 = aInnA1*3.3f;
printf("$VOLTAGE,A1,%.2f\r\n" ); // This sends value back to the program
}
int main()
{
Vcc=1; Gnd=0;
char e [9];
while(1)
{
scanf("%[^\r\n]s",e); // Reads my input from the program
float d = atof(e);
if (voltage1 > d )
{
myled = 1;
}
if (voltage1 < d ) //
{
myled = 1;
wait(0.1);
myled = 0;
wait(0.1);
}
}}