Hi All,
This is my first mbed forum post as I only got my mbed 3 days ago.
I have been trying to control LED1 brightness via a .net (VB) program communicating over serial connection to the mbed. I have been having issues with sending floats from .net to mbed. A simplified version of the server .net code is shown below:
Imports System
Imports System.IO.Ports
Public Class Form1
Dim MyPort As New SerialPort("COM4", 9600, Parity.None, 8, StopBits.One)
Dim brightness as Double = 0.02
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not MyPort.IsOpen Then MyPort.Open()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MyPort.WriteLine(brightness)
End Sub
This mbed code is shown here (a modified version of the "u" "d" tutorial:
#include "mbed.h"
Serial pc(USBTX, USBRX);
PwmOut led(LED1);
float brightness = 0.0;
int main() {
while (1) {
float c = pc.getc();
brightness = c;
led = brightness;
}
}
It is probably something to do with the getc() function. I have tried scanf("%f",brightness) but this seems not to yield a result.
I hope this is something obvious I am missing.
Thanks in advance.
GuerrillaCoder
Hi All,
This is my first mbed forum post as I only got my mbed 3 days ago.
I have been trying to control LED1 brightness via a .net (VB) program communicating over serial connection to the mbed. I have been having issues with sending floats from .net to mbed. A simplified version of the server .net code is shown below:
This mbed code is shown here (a modified version of the "u" "d" tutorial:
I hope this is something obvious I am missing.
Thanks in advance.
GuerrillaCoder