The communication between USBIZI (a .NET Micro Framework enabled ARM7 MCU system) and Arduino can be easily implemented using I2C, SPI, as well as UART.
In addition to these, USBIZI can also act as a USB host (like the PC), which allows Arduino to be plugged in (on the USB bus) directly, owing to its FTDI usb<-->uart component.
Here is the sample code http://www.microframeworkprojects.com/project/31
which can be adapted for the Arduino:
int data;
void setup()
{
Serial.begin(115200);
}
void loop()
{
if(Serial.available()>0)
{
data = Serial.read();
data = data + 1;
Serial.print(data,BYTE);
}
}
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using System.IO.Ports;
using GHIElectronics.System;
using GHIElectronics.Hardware;
using GHIElectronics.System.SystemDevices;
namespace arduinoHost
{
public class Program
{
//LED
static OutputPort LED = new OutputPort(USBizi.Pins.E2x, false);
//arduino FTDI USB host
public static SerialUSB serial;
static ManualResetEvent e = new ManualResetEvent(false);
//message sent to Arduino
public static Byte[] data = new byte[1];
public static void Main()
{
SystemManager.Start(SystemManager_SystemEvent);
//wait till arduino plugged in
e.WaitOne();
while (true)
{
try
{
data[0] = 123;
serial.Write(data, 0, 1);
serial.Read(data, 0, 1);
if (data[0] == 124)
{
LED.Write(true);
Thread.Sleep(100);
LED.Write(false);
}
else
LED.Write(false);
}
catch
{
}
Thread.Sleep(1000);
}
}
static void SystemManager_SystemEvent(SystemEventType type, SystemEventArgs args)
{
if (args.isDeviceConnected)
{
if (args.device.deviceType == DeviceType.Serial_FTDI)
{
serial = new SerialUSB(args.device, 115200, 0, 8, 0);
serial.Disconnected += new SerialUSBEventHandler(serial_Disconnected);
serial.Open();
serial.ReadTimeout = 500;
serial.DiscardInBuffer();
e.Set();
}
}
}
static void serial_Disconnected(SerialUSB sender, SerialUSBEventArgs msg)
{
LED.Write(true);
serial = null;
}
}
}