Control an Arduino Uno from Igor

A proof of concept to control an Arduino Uno from Igor using the VDT2 XOP on Macintosh.

Arduino code:
int incomingByte = 0;<br />
boolean space = false;<br />
<br />
void setup() {                <br />
  // initialize the digital pin as an output.<br />
  // Pin 13 has an LED connected on most Arduino boards:<br />
  pinMode(13, OUTPUT);<br />
  Serial.begin(9600);<br />
<br />
}<br />
<br />
void loop() {<br />
  if (Serial.available() > 0) {<br />
    incomingByte =;<br />
    if (incomingByte == 32) {<br />
      space = true;<br />
      digitalWrite(13, HIGH);   // set the LED on<br />
    }<br />
    else {<br />
      space = false;<br />
      digitalWrite(13, LOW);    // set the LED off<br />
    }<br />
  }<br />

- Load the code to the Arduino Uno.
- Put a link to the VDT2 XOP in the Igor Extensions folder.
- Having the Arduino connected via USB to your Mac (re)start Igor.

Then you can use VDTGetPortList2; print S_VDT to show a list of all available serial ports. Choose the one that is provided by the Arduino board (it starts with 'usbmodem'), e.g. VDTOperationsPort2 usbmodemfa131.
You can then switch the LED at Pin 13 on with VDTWrite2 /O=2 " " and off again by some other character than space (VDTWrite2 /O=2 "x").