Pages: [1]   Go Down
Author Topic: audio  (Read 704 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Everyone, I need help 

So far, I've got the motor to move a certain angle
when the LED comes on.
When the motor is triggered I want the audio file to play from the pc.
(i will be connecting pc speakers to the arduino).

Basically, I need help on how to do the following steps:-

1. The Arduino checks for a signal from the sensor. if there is a signal, it sends a signal through USB to my laptop.
2.  The program written in Processing checks for signals from the Arduino on my USB port. If there is a signal, it plays the file.

Can anyone help? ;(
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33371
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well for a start please delete your othe thread on the same topic, cross posting is a no no round here.
You need to supply more information, what sensor? How is it connected?
What sort of motor, I assume it is a servo but you don't say.
What code have you tried? Can you post it.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@op

Please stop cross-posting. Copying and pasting the same question just annoys people. Your posts will be seen. They are likely to be ignored if you spam the board.
Logged

Miami/Florida
Offline Offline
Sr. Member
****
Karma: 14
Posts: 342
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, I thought those threads I copied and pasted will be usefull for him as they describe most of what he is trying to do. I erased it.
Logged

Perseverance is 90% of the solution. The remaining 10% is more perseverance.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I wasn't addressing my comment to you arduinoadrian. Useful links are always appreciated.
Logged

Miami/Florida
Offline Offline
Sr. Member
****
Karma: 14
Posts: 342
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh Ok. Sorry. Will post again.

Check this out.

In these threads you will find answers to most of the same questions. They were discussed here recently.

http://arduino.cc/forum/index.php/topic,93323.msg703752.html#msg703752
http://arduino.cc/forum/index.php/topic,101231.0.html
Logged

Perseverance is 90% of the solution. The remaining 10% is more perseverance.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

smiley-grin thanks everyone (and i have deleted the other posts— sorry!)

i'm using a LDR to turn the LED on without light
and the LED will trigger the Servo Motor to a certain degree of angle.

since i cannot find much information with what i originally wanted to do with the sound,

i've decided to get a Waveshield and SD/MMC card to play the sound from the library as the motor moves.

Hopefully it will work.. and arrive in time! smiley
« Last Edit: April 17, 2012, 06:05:42 am by oddthumb » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As I have not enough time to wait for the waveshield
I tried to find another way of playing the music file.

But im getting an error ;<

This is the code I used:-

#include <Servo.h>
import ddf.minim.*;
import processing.serial.*;

#define MOTOR 4 //motor is plugged in to pin 4
#define SENSOR 7 //button is plugged in to pin 7
#define LED 13

int trigger = 1;//if button's not pressed, trigger = 0, else trigger = 1

Minim minim;
AudioPlayer player;

Servo myservo;

void setup()//initializing
{

minim = new Minim(this);
player = minim.loadFile("filename.mp3",2048);

port = new Serial(this, Serial.list()[MOTOR],9600);

size(10,10);

myservo.attach(MOTOR);

pinMode(LED , OUTPUT);
pinMode(SENSOR , INPUT);
//setting button(7) as an INPUT
}


int move = 0;//movement of the motor in degrees(angle)


void loop()
{
trigger = digitalRead(SENSOR);
//checks if the button is pressed or not

if(trigger == 0)//if the sensor detects darkness
{//move the motor

digitalWrite(LED , HIGH);

delay(2000);//wait for 2 seconds

//moves the motor 30 degrees 0 to 30
//move += 1 increments the value of move by 1
for(move = 0; move < 30; move += 1)
{
myservo.write(move);//move the motor by the given value

delay(4);//waits for 4ms
}//end of for

player.play();

delay(1000); //wait for 1 sec

//this for loop moves back the position of the motor from 30 degrees to 0
//move -= 1 decrements value of move by 1
for(move = 30; move >= 0; move -= 1)
{
myservo.write(move);
delay(5);
}
delay(1000);

}//end of if
else
digitalWrite(LED , LOW);


}

void stop()
{
player.close();

minim.stop();

super.stop();

}


The error msg says, import does not name a type???
I'm not sure what im doing wrong :S
« Last Edit: April 18, 2012, 05:33:15 am by oddthumb » Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You appear to be trying to compile a cross between Processing code and Arduino code in the Arduino IDE.

Minim is a library for Processing.
Servo.h is a library for Arduino.
« Last Edit: April 18, 2012, 05:52:48 am by dxw00d » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

;( will i have to use something like Firmata to do this????????????
(sorry im new to all of this @@)
« Last Edit: April 18, 2012, 06:11:03 am by oddthumb » Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could do. I've never used Firmata, so I don't know if it will help you.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
will i have to use something like Firmata to do this?
No. Absolutely, positively, no.

Firmata puts your Arduino in the role of a slave, entirely driven by Processing or some other Firmata-aware application. That is most certainly not what you seem to be trying to do. You seem to want the Arduino to be the master, controlling Processing.
Logged

Miami/Florida
Offline Offline
Sr. Member
****
Karma: 14
Posts: 342
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Seems to me  you are really beginning with this. I will try to help.

You need to have one sketch (program) for Arduino and another for your computer in Processing (you have chosen Processing it could be another language). Two different sketches that will work together to do what you want. Processing and Arduino IDE are very similar; but still 2 different things.

in Processing you need to have a void draw() function for it to run in a loop, otherwise blank screen and no program running. You need to study Processing here:
http://processing.org/

I don't know what you are doing; but seems like a good starter project that will help you learn many good things. In order to give you more specific advise you need to study some Processing on your own first and come up with some sketch for you to understand what it is all about. You will find help here.

 
Logged

Perseverance is 90% of the solution. The remaining 10% is more perseverance.

Pages: [1]   Go Up
Jump to: