Pages: [1]   Go Down
Author Topic: a relay or another way?  (Read 1091 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I am a new member with very little knowledge of electronics and would appreciate any input from more knowledgeable members.

I am trying to use the Arduino Uno to send a signal into Max4Live to trigger a sample in Ableton Live.
The way I want to create the initial signal is to make this simple circuit;
My guitar, with a steel string is pressed down as normal onto one of the frets to make a note as normal,
a copper wire is wrapped around the fretboard to provide a conductive strip,
one crocadile clip is attached to the guitar string at the headstock (where the tuning keys are)
a length of copper wire extends from this crocadile clip to the Arduino.
Another crocadile clip is attached to the copper wire wrapped around the fretboard and extended to the Arduino to complete the circuit when the guitar string is pressed onto the conductive strip (wire).

My question is what do I need to use and how do I connect to the Arduino Uno to send a simple on/off state?
I want to be able to play the notes as normal on the guitar and just use a trigger point provided by this arrangement to activate the circuit - on then off, with each press of the string on that particular fret while continuing to play.
Any ideas? can this be done?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Connect the string to an arduino input pin. Connect the fret to a ground pin. Run a simple read the input pin & react program:

Code:
byte pinX = 2; // pin D2 for instance
byte pin13 = 13; // onboard LED on D13

void setup(){
pinMode (pinX, INPUT);
digitalWrite pinX, HIGH); // turn on internal pullup resistor

pinMode (pin13, OUTPUT);
digitalWrite (pin13, LOW); // turn the LED off to start
} // end void setup

void loop(){
// now when string is pressed to the fret, the input pin is connected to ground.
if ( digitalRead (pinX) == LOW ){
// when the pin is grounded turn on the onboard LED
digitalWrite (pin13, HIGH);
}
// otherwise turn the LED off
else{
digitalWrite (pin13, LOW);
}
} // end void loop
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

Hi CrossRoads, thanks for your help. I tried your code but the Arduino expected a ';' before ')' token. when I added this it then expected a primary-expression before ')' token. Do you know what this means please?
Logged

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

It means you missed out a ; in the line above where the error is flagged.
Logged

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

Thanks Grumpy Mike.
I have the code working now, the next thing I would like to do with this set up is to make the Arduino trigger an audio sample instead of just turning the led on and off.
Does anyone know how to change the if/else code to make this happen?
I have Max MSP, Maxuino, Firmata and Ableton Live but it seems that I could achieve what I want with just the Arduino. Is this possible?
Thanks.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should know that your guitar string "switch" is contact bouncy as all heck.
For an led, quick micro flashes are no problem.   If you are triggering something or counting something
that's a different story.
To check this try modifying your code to count the fret triggerings.
Press the string twice.   You will get MANY counts.
De-bouncing software or hardware is in many places on this forum.

Good luck.  Like your attitude.
Logged

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

Well, to try to clarify, what I really want to do is this - I want the guitar string and contact strip switch to send a signal from the Arduino into Maxuino which is running in Ableton Live.
When Ableton Live successfully receives the signal it will then trigger an audio sample each time I press the guitar string down onto the fret containing the contact strip.
The code above from CrossRoads works perfectly to turn the led on and off, but to send a signal from Arduino into Maxuino I have to use Standard Firmata code and this is now the problem.
The code above works within Arduino but Maxuino requires different code to trigger events in Ableton Live.
Any Ideas?
Logged

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

You do NOT have to use Firmata to do what you want.
Those two programs have to do some of the work. That is they recieve the message, and take the appropriate action. This is not an arduino problem but one with the code in Ableton.
Logged

Pages: [1]   Go Up
Jump to: