Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Re: Arduino buzz wire game on: December 11, 2012, 10:28:14 am
Hey i think this is where the delay is, in the code for the background animation
Code:
void loop()
{
val1 = digitalRead(BUTTON1); //read input value from button1
//check if there was a transition
if (val1 == HIGH) { //if we touch the start point
Serial.println ("1");
digitalWrite (LED, HIGH);
delay (100000);
}
if (val1 == LOW ) { //if nothing happens
digitalWrite ( LED, LOW);
}

I set the delay to (100000)...in order to play the whole animation... but it seems that I can't skip it once I press the 1st button I have to wait until it ends so we cant play a short scary animation in between(when the wire is touched) while the background animation is playing? is there any way we can interrupt the signal for about 2 seconds to play this short clip to scare people when they touch the wire and then continue playing the background animation again?

I found a thing called "hardware" interrupt could you explain this to me please smiley does it mean I can interrupt the background animation when I press another button, can we use this?  can I use the second button to be the interrupt trigger ?
Will it be able to stop the first animation and play another one, then go back to that loop animation after the interrupt one is finished?


thank you again you've been a great help smiley
2  Using Arduino / Project Guidance / Re: Arduino buzz wire game on: December 10, 2012, 10:09:54 am
thanks very much smiley thats worked smiley yippy 

Is there any way to speed up the time from when we touch the wire to playing movie? because there is a delay of 30 seconds, is that because of my computer/iTunes? would it be less of a delay if I used VLC or quicktime? ill show you the code incase there is a problem with that?

Arduino
Code:
const int BUTTON = 7;
const int LED = 13;

int val = 0;    //variable to store the state of the button
int old_val = 0;  //stores the previous value of "val"
int state = 0;    // 0 = BUTTON off while 1 = BUTTON on
unsigned long startTime = 0;   // when did we begin pressing?
char animation = 'A';    // the scary animations
char myChar = 'B';       //the normal aniamtion


void setup()
{
  pinMode(BUTTON,INPUT);    //BUTTON is an input
  Serial.begin(9600);       //open the serial port to send data back to the computer
                          //at 9600 bits per second
}
void loop()
{
  val = digitalRead(BUTTON);      //read input value from the button
  //check if there was a transition
  if (val == HIGH) {               //if we buzz the wire
    Serial.println ("A");
    digitalWrite (LED, HIGH);
    delay (1000);
  }
  if (val == LOW ) {               //if nothing happens
    Serial.println ("B");
    digitalWrite ( LED, LOW);
  }
}

Applescript
Code:
set arduinoPort to "/dev/cu.usbmodemfa131"
-- this opens the port and resets the arduino
set arduino to serialport open arduinoPort bps rate 9600 data bits 8 parity 0 stop bits 1 handshake 0
if arduino is equal to -1 then
display dialog " could not open port "
else
repeat -- repeat forever
-- wait until something is sent
set bytesIn to 0
repeat until bytesIn is not equal to 0
set bytesIn to serialport bytes available arduino
end repeat
set cmd to serialport read arduino for 1
set cmds to cmd as string
-- display dialog "Command recieved = " & cmds

if cmds is equal to "A" then
tell application "iTunes"
tell (some track of playlist "test") to play
end tell
end if



end repeat -- of the forever repeat
-- note this next bit will reset the arduino
serialport close arduino
end if

Were also adding two buttons so would that be a factor in the delay?

thank you again smiley
3  Using Arduino / Project Guidance / Re: Arduino buzz wire game on: December 09, 2012, 02:48:30 pm
hey

weve tried the script you sent us and it works smiley-grin but then we tried to write the script to run iTunes by our selves but we dont know weather its correct or not and we do we dont know how to combine them in the script you gave us (or do we  need to combine them ? or just save them separately?

heres the two scripts written by ourselves, to make an animation looping in the background  and the other is to trigger random animations when the player buzzes the wire

tell application "iTunes"
     
      tell (track 1 of playlist "normal") to play

end tell

...

tell application "iTunes"
     
      tell (some track of playlist "test") to play

end tell


4  Using Arduino / Project Guidance / Re: Arduino buzz wire game on: December 06, 2012, 10:18:46 am
yea we have used apple script but the signal is not revived to turn the play list on that we have created in iTunes  but the hot keys work but we were wondering if we need a middle program to translate the signal from arduino to the apple script? ill post you are code cause we can't get it to work :s if were doing it right smiley


const int BUTTON = 7;
const int LED = 13;

int val = 0;    //variable to store the state of the button
int old_val = 0;  //stores the previous value of "val"
int state = 0;    // 0 = BUTTON off while 1 = BUTTON on
unsigned long startTime = 0;   // when did we begin pressing?
const byte ANIMATION = 3;
char* names[ANIMATION] = {
  "ctrl A","ctrl B","ctrl C"
};

void setup()
{
  pinMode(BUTTON,INPUT);    //BUTTON is an input
  Serial.begin(9600);       //open the serial port to send data back to the computer
                          //at 9600 bits per second
}
void loop()
{
  val = digitalRead(BUTTON);      //read input value from the button
  //check if there was a transition
  if (val == HIGH) {               //if we buzz the wire
    Serial.println (names[random(0,ANIMATION)]);
    digitalWrite (LED, HIGH);
    delay (1000);
  }
  if (val == LOW ) {               //if nothing happens
    Serial.println ("Normal state");
    digitalWrite ( LED, LOW);
  }
}

here is the apple  script for one of the hot keys

tell application "iTunes"
   tell (track 1 of playlist "test") to play
   
end tell


thank you again smiley-grin
5  Using Arduino / Project Guidance / Re: Arduino buzz wire game on: December 06, 2012, 04:51:25 am
Hey
thanks very much for a reply
we have got a signal going to the mac from the arduino but we cant figure out how to change the signal into commands that could play videos on a media player.
Is there any programes you would recommend to use to wait for the message from the arduino and then play the video?

thanks very much
6  Using Arduino / Project Guidance / Arduino buzz wire game on: December 04, 2012, 08:47:58 am
Hey

We were wondering if anyone could help us.

We are creating an interactive buzz wire game for our second year university project and were wanting to trigger a different animation each time the wire is touched

We have created a simple circuit and code in arduino to turn an LED on when a button is touched and have now changed the button to a wire but we need help trying to change the LED to some sort of media player on mac.
We are trying to use VLC but would you recommend anything else we should use that is more straight forward....

We are very new to programming and have a general knowledge of processing but not a great deal so as much help would be much appreciated  smiley-grin

ps. we have seen some websites telling us how to use "terminal" to activate VLC (and done this) but we are not sure how to connect this with arduino?

thanks so much for any help you can give us smiley-grin

Thank you
Pages: [1]