Video projection

Hi,

Im pretty new to all this but i have been working on a video projection wich is triggered buy a pressure pad on a seat. The problem is that i have an old Director mx program that runs the various videos from a key press script using keys like "e" and "r". I thought it would be possible to activate this through an Arduino button press sketch. I have tried running AAC keys on my mac to convert it into a key stroke so while the director projector is running it will emulate the keyboard.

The serial.print works in the serial monitor but dosnt convert to an actual key press as i thought it might. one thing I noticed is that the Arduino uses the /dev/tty.usbmodemfd131 serial port and AAC keys is using the bluetooth-PDA_sync serial port could this be why!

Hope this makes sense and I hope u can help

cheers and thanks

P.

Welcom on the forum,

Please post your arduino code so we can check if it does what it should do
(The MAC part I cannot help you with, is AAC keys a free program or part from Director?)

Director needs to be looking at the same port as the arduino is on. Can you change what director is looking at?

@robtillaart

This is the code I was trying to use:

const int buttonPin = 2; // the number of the pushbutton pin

int buttonState = 0; // variable for reading the pushbutton status

void setup() {

pinMode(buttonPin, INPUT);
Serial.begin(9600); // open the serial port at 9600 bps:
}

void loop(){

buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {
Serial.println("e");
}
else {
// nothing
}

}

AAC Keys is a free program I found here :

http://www.aacinstitute.org/Resources/ProductsandServices/AACKeys/AACKeys.html

@Grumpy_Mike

O.k I will have a look and see if I can do that im not to sure!

Here is the Director script

-- Main Movie Script:

on startMovie
initialiseGlobals()
end

global gTheKeys, gKeysTriggered
global gActivePads, gReEnter

on initialiseGlobals
-- Reset everything:
gTheKeys = ["e", "r", "p"]
gKeysTriggered = [0, 0, 0]

gActivePads = [0, 0, 0] -- [0,0,0]=NONE, [1,0,0]=LEFT, [0,1,0]=RIGHT, [1,1,1]=BOTH
gReEnter = 0
end

on detectKeyInputs
repeat with i = 1 to 3
if keyPressed(gTheKeys.getAt(i)) then
gKeysTriggered.setAt(i, 1)
else
gKeysTriggered.setAt(i, 0)
end if
end repeat
end

on resetMovie
go to "initMovie"
end

-- Timer script, used to filter out unwanted keypresses, sorta like a threshold:
global gTrackLeft, gTrackRight
global gTimeInterval, gHistoryLength, gHistoryCounter

on initTimer
gTimeInterval = .25 * 60
gHistoryCounter = 1
gHistoryLength = 10
--init the list to store the keypresses
gTrackLeft = []
gTrackRight = []
repeat with i = 1 to gHistoryLength
gTrackLeft.append(0)
gTrackRight.append(0)
end repeat

startTimer
end

on recordKeyHistory
if the Timer > gTimeInterval then

-- set list positions:
gTrackLeft.setAt(gHistoryCounter, (gKeysTriggered.getAt(1))) -- update from left key
gTrackRight.setAt(gHistoryCounter, (gKeysTriggered.getAt(2))) -- update from right key

-- move to next position
if gHistoryCounter >= gHistoryLength then
gHistoryCounter = 1
else
gHistoryCounter = gHistoryCounter + 1
end if
-- put gHistoryLength
-- put gHistoryCounter
--put gTrackLeft
-- put gTrackRight
startTimer
end if
end

on getFilteredKeyInput
valL = 0
valR = 0
repeat with i = 1 to gHistoryLength -- count number of 1's (ON) in the list.
if gTrackLeft.getAt(i) = 1 then -- LEFT key
valL = valL + 1
end if
if gTrackRight.getAt(i) = 1 then -- RIGHT key
valR = valR + 1
end if
end repeat

if valL > (gHistoryLength/2) then -- is more than half the list = 1 / ON?
gActivePads.setAt(1, 1) -- yep it is
else
gActivePads.setAt(1, 0) -- nope it aint
end if

if valR > (gHistoryLength/2) then -- ditto for the RIGHT key
gActivePads.setAt(2, 1)
else
gActivePads.setAt(2, 0)
end if

-- If both LEFT and RIGHT active then light up position 3 in the list!
if gActivePads.getAt(1) = 1 and gActivePads.getAt(2) = 1 then
gActivePads.setAt(3, 1)
else
-- or not!
gActivePads.setAt(3, 0)
end if
end

on updateKeys
getFilteredKeyInput()
end

@Grumpy_Mike

Ive been looking at the arduino + director posts in the playground and tried following instructions for the serial extra but keep getting mixed up with things as its a bit above my head at the moment. do i need to implement something in the director script to point to the right serial port im not sure how to go about this.

so basicly you want the arduino to act as a keyboard? a keyboard that sends the keystrokes 'e' and 'r' ? then i have the solution for you:

http://code.google.com/p/vusb-for-arduino/
http://www.practicalarduino.com/projects/virtual-usb-keyboard

(both the same project, but the last one with example setup)

Nick

You need to do what it says here:-
http://userwww.sfsu.edu/~infoarts/technical/arduino/wilson.arduinoresources.html

In particular you need to:-

Get a copy of Serial Xtra by Geoff Smith and place it in the Xtras folder located in your Director folder.

Get a copy of Steve Wilson's Template (Wilson.arduinotemp13.dir ) program - it contains examples of the routines in Director that allow it to talk to the Arduino board - sending and receiving commands and information.

@Grumpy_Mike

O.K sorry about that :cold_sweat:

I have been looking at the links u sent and have tried following them copyed the Serial Xtra by Geoff Smith and placed it in the Xtras folder in my Director folder but not sure if i follow Steve Wilson's Template think i pointed to the right serial port but not sure what to do after!! do i just copy that on top of my main movie scrippt and export the progector again.

Thankyou for ur help.

@Steen

yes Nick thats basically what i need do i just upload that code and connect the mats for it to work? was trying some of the ps2 keyboard codes and was getting a few errors not enough experience to figure it out :blush:

do i just copy that on top of my main movie scrippt and export the progector again.

I am not sure, it must be 20 years since I looked at director and a lot has probably changed since then. It is worth a try.

@ Grumpy_Mike
Yes it was a while ago I done this code and cant remember much of it thanku again for your help.