Hello I’m trying to send sensor reading every 20 ms back to another application im running on my laptop. I’m using Fez Panda 2 (FEZ Ultimate Kit) . From what I understand i need to upload program to Panda and then connect Serial-to-USB E- Block(COM7 on my laptop) to start receving data…Taken from http://www.ghielectronics.com/downloads/FEZ/FEZ_Internet_of_Things_Book.pdf
SerialPort UART = new SerialPort(“COM7”, 115200);
int read_count = 0;
byte[] rx_byte = new byte[1];
UART.Open();
public static void Main()
{
AnalogIn lightSensor = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
double lightSensorReading = 0;
Is there something that I’m missing or can it be done diffrently? All im trying to do is to pass data like its passed with: Debug.Print(lightSensorReading.ToString());
Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the
tags or...
Select the code within your post and click the "101010" icon.[/ol]
secondly...
what exactly is not working? you do not state this in your post.
Hey I have sensor connected on the board on analog pin. With the code bellow I get values of sensor to output window of debugger in Visual Studio.
Code:
public static void Main()
{
AnalogIn lightSensor = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
double lightSensorReading = 0;
while (true)
{
lightSensorReading = lightSensor.Read();
Debug.Print(lightSensorReading.ToString());//I want this values that are printed in debug window in another application
Thread.Sleep(20);
}
}
Output of debugger:
447
476
477
447
477
477
447
476
477
447
476
477
So what I’m actually trying to do is to use this values that i get on analog pin in another c# Windows Forms application (or Java etc)
So I understand that i can do that trough serial port connecting Serial Port E-block and send all readings I get on analog pin trough serial port so I can get values in anoter application with next code:
your 20msec expectation is something you should ignore for now; it’s unlikely that your code will run in 20msec let alone send data in that timeframe (serial is SLOW, relatively speaking). So first thing I would suggest you do is change that thread.sleep to be 500; get the fundamentals working before you optimise and shrink the timing.
The next step is to get your PC communicating over serial port, back to a terminal program on a PC. Until you do that and prove that works, don’t worry about writing a PC application.