Tutorial.EsploraRemote History

Hide minor edits - Show changes to markup

December 24, 2012, at 03:58 AM by Tom Igoe -
Added lines 43-44:

NOTE: Serial ports on a computer can only be accessed by one program at a time. If you have the Arduino IDE's Serial Monitor open, then the Processing Sketch will not be able to access the Esplora's serial port. Likewise, if the Processing sketch is still running, you won't be able to open the Serial Monitor or reprogram your Esplora.

December 24, 2012, at 03:33 AM by Tom Igoe -
Changed lines 9-10 from:

Download the zip file containing the Processing sketch for this example.

to:

There are two Processing sketches that work with this example, a simple one that prints the sensors in text, and a more complex one that shows a graphic representation of the Esplora. The former may be better for beginning Processing programmers, and the latter may be better for advanced Processing programmers.

Download the zip file containing the simple Processing sketch for this example.

Download the zip file containing the advanced Processing sketch for this example.

December 23, 2012, at 06:09 PM by Scott Fitzgerald -
Changed lines 40-41 from:
to:

/*
  Esplora Remote
 
 This sketch allows to test all the Esplora's peripherals.
 It is also used with the ProcessingStart sketch (for Processing).
 
 When uploaded, you can open the Serial monitor and write one of
 the following commands (without quotes) to get an answer:
 
 "D": prints the current value of all sensors, separated by a comma.
 See the dumpInputs() function below to get the meaning of
 each value.
 
 "Rxxx"
 "Gxxx"
 "Bxxx": set the color of the RGB led. For example, write "R255"
 to turn on the red to full brightness, "G128" to turn
 the green to half brightness, or "G0" to turn off
 the green channel.
 
 "Txxxx": play a tone with the buzzer. The number is the
 frequency, e.g. "T440" plays the central A note.
 Write "T0" to turn off the buzzer.
 
 
 Created on 22 november 2012
 By Enrico Gueli <enrico.gueli@gmail.com>
 Modified 23 Dec 2012
 by Tom Igoe
 */


#include <Esplora.h>

void setup() {
  while(!Serial); // needed for Leonardo-based board like Esplora
  Serial.begin(9600);
}

void loop() {
  if (Serial.available())
    parseCommand();
}

/*
 * This function reads a character from the serial line and
 * decide what to do next. The "what to do" part is given by
 * function it calls (e.g. dumpInputs(), setRed() and so on).
 */

void parseCommand() {
  char cmd = Serial.read();
  switch(cmd) {
  case 'D':
    dumpInputs();
    break;
  case 'R':
    setRed();
    break;
  case 'G':
    setGreen();
    break;
  case 'B':
    setBlue();
    break;
  case 'T':
    setTone();
    break;
  }
}

void dumpInputs() {  
  Serial.print(Esplora.readButton(SWITCH_1));
  Serial.print(',');
  Serial.print(Esplora.readButton(SWITCH_2));
  Serial.print(',');
  Serial.print(Esplora.readButton(SWITCH_3));
  Serial.print(',');
  Serial.print(Esplora.readButton(SWITCH_4));
  Serial.print(',');
  Serial.print(Esplora.readSlider());        
  Serial.print(',');
  Serial.print(Esplora.readLightSensor());    
  Serial.print(',');
  Serial.print(Esplora.readTemperature(DEGREES_C));
  Serial.print(',');
  Serial.print(Esplora.readMicrophone());    
  Serial.print(',');
  Serial.print(Esplora.readJoystickSwitch());
  Serial.print(',');
  Serial.print(Esplora.readJoystickX());      
  Serial.print(',');
  Serial.print(Esplora.readJoystickY());      
  Serial.print(',');
  Serial.print(Esplora.readAccelerometer(X_AXIS));
  Serial.print(',');
  Serial.print(Esplora.readAccelerometer(Y_AXIS));
  Serial.print(',');
  Serial.print(Esplora.readAccelerometer(Z_AXIS));
  Serial.println();
}

void setRed() {
  Esplora.writeRed(Serial.parseInt());
}

void setGreen() {
  Esplora.writeGreen(Serial.parseInt());
}

void setBlue() {
  Esplora.writeBlue(Serial.parseInt());
}

void setTone() {
  Esplora.tone(Serial.parseInt());
}

December 10, 2012, at 04:33 PM by Scott Fitzgerald -
Changed lines 5-13 from:

This example is thought to be used in combination with a Processing sketch. The application on the computer has the task to read all the sensors present on the board and command the buzzzer and the RGB led displaying it in a graphical user interface with the Esplora board shape. In effects, your Esplora board will be remoted on your computer screen.

If you don't have Processing installed on your computer, you can also test this example opening the serial monitor and interacting with the Esplora trough the serial commands.

Downoload here the zip file containing the Processing sketch for this example. You only need to unzip this folder inside the Processing sketchbook and run it launching the Processing IDE.

to:

This example is designed to be used with a Processing sketch. Processing is an open source programming environment. The application on the computer reads the sensors on the Esplora board and controls the buzzer and the RGB LED through a graphical interface. The image in the Processing application mirrors the Esplora board, so you'll see a virtual version of your board.

If you don't have Processing installed on your computer, you can also test this example opening the serial monitor and interacting with the Esplora trough serial commands.

Download the zip file containing the Processing sketch for this example.

You only need to unzip this folder inside your Processing sketches folder, and open the .pde file in Processing.

Added lines 16-18:

Software Required

  • Processing
Changed lines 31-37 from:

This example provide a serial interface to the Esplora, so you ask to read the sensors or write on the buzzer or on the RGB led only sending commands to the serial port to the Esplora. The commands always starts with a character, that indicates which operation you want to perform followed by the value you want to write to the actuator or the number of samples you want to collect.

Using this sketch in combination with the one wrote in Processing, lift you to the task of typing the commands on the serial port, but will use the same protocol to talk with the board. Every value of the sensor will be displayed on the remote Espora drawed on the computer screen, and you can command the buzzer and the RGB led with sliders, just clicking on the component.

to:

This example opens a serial interface to the Esplora. You'll ask the board to read the sensors or write to the buzzer or RGB LED by sending commands over the Esplora's serial port.

The commands always starts with a character, which indicates the operation you want to perform followed by the value you want to write to the actuator or the number of samples you want to collect.

Using this sketch in combination with the application written in Processing, allows you to control the board with a graphical interface, instead of typing the commands through the serial port. It is still possible to control the board by manually entering commands in the serial monitor or serial application.

All sensor values will be displayed on the Esplora drawn on the computer screen, and you can command the buzzer and the RGB led with sliders, clicking on the component.

December 10, 2012, at 12:34 PM by Federico -
Changed line 11 from:

Downoload here? the zip file containing the Processing sketch for this example.

to:

Downoload here the zip file containing the Processing sketch for this example.

December 10, 2012, at 12:30 PM by Federico -
Changed lines 11-13 from:
to:

Downoload here? the zip file containing the Processing sketch for this example. You only need to unzip this folder inside the Processing sketchbook and run it launching the Processing IDE.

December 10, 2012, at 11:52 AM by Federico -
Changed line 35 from:
to:
December 08, 2012, at 08:13 PM by Federico -
Added lines 1-41:

Share