¡Saludos!
Estoy con un proyecto personal y necesito que mi placa Arduino interaccione por serial con Blender. He encontrado algunos ejemplos por Internet, pero no me funcionan.
No sé si alguien de por aquí tiene por mano Blender y Python además de Arduino y puede decirme qué está mal.
Utilizo Linux (concretamente Ubuntu) y la versión de Blender 2.62 .
El código para mi Arduino Duemilanove es este:
int ledPin13 = 13; // select the pin for the LED
int ledPin12 = 12; // select the pin for the LED
int ledPin11 = 11; // select the pin for the LED
int ledPin10 = 10; // select the pin for the LED
int ledPin9 = 9; // select the pin for the LED
int ledPin8 = 8; // select the pin for the LED
// int inPin = 7;
void setup()
{
pinMode(ledPin13,OUTPUT); // declare the LED's pin as output
pinMode(ledPin8,OUTPUT); // declare the LED's pin as output
pinMode(ledPin9,OUTPUT); // declare the LED's pin as output
Serial.begin(9600); // connect to the serial port
Serial.println("Arduino is ready");
} //setup
void loop ()
{
int serbyte = 0;
serbyte = Serial.read();
// if the input is '-1' then there is no data
if (serbyte != -1)
{
if (serbyte == 'H')
{
digitalWrite(ledPin13, HIGH);
}
if (serbyte == 'L' )
{
digitalWrite(ledPin13, LOW);
}
if (serbyte == '1')
{
digitalWrite(ledPin9, HIGH);
}
if (serbyte == '0' )
{
digitalWrite(ledPin9, LOW);
}
if (serbyte == 'h')
{
digitalWrite(ledPin8, HIGH);
}
if (serbyte == 'l')
{
digitalWrite(ledPin8, LOW);
}
} // if
} //loop
y el código en python para Blender:
#!/usr/bin/env python
import serial
ser = serial.Serial('/dev/ttyUSB0', 9600)
ser.write('H')
También he instalado la librería serial de python en la carpeta bin/blender-2.62/2.62/python/lib/python3.2 , que es dónde tengo el resto de librerías python.
El código de Arduino no me da ningún problema. Ahora bien, cuándo le doy al Run Script de Blender, me dice que hay errores en el fichero init.py de la librería serial.
¿Alguien sabe cuál puede ser el problema?
Gracias de antemano