Loading...
  Show Posts
Pages: [1] 2 3 ... 10
1  Using Arduino / Programming Questions / Re: hold last sensor value on: December 13, 2012, 11:05:14 am
I am trying the else I can still not dynamically update the value without releasing.
exactly the same as before


Code:
#include <MIDI.h>
#define LED 13

int sensorPin = A0;
int tempVal = 0;
int led = 13;
int note = 0;
int scale[] = {
  60,62,64,65,67,69,71};


void setup() {
  pinMode(LED, OUTPUT);
  MIDI.begin();
}

void loop(){
  tempVal = analogRead(sensorPin);

  if(tempVal == 0) {
    MIDI.sendControlChange(123,0,1); // OMNI NOTE OFF MSG
    digitalWrite(led, LOW);
  }

  else if (tempVal > 1) {
    note = map(tempVal, 1023, 1, 6, 0);
    note = constrain(note, 0, 6);
    MIDI.sendNoteOn(scale[note],127,1);
    digitalWrite(led, HIGH);
  }
}
2  Using Arduino / Programming Questions / Re: hold last sensor value on: December 13, 2012, 10:22:52 am
Quote
I don't really understand what you are doing.

Me neither, hence my posting in the forum "programming questions"  smiley

Quote
Code:
    posVal = tempVal;
    posVal = map(posVal, 1023, 1, 127, 0); // make midi notes
    posVal = constrain(posVal, 0, 127); // constrain it
Why? You never use posVal anywhere else.
Its a remain from previous iterations. Does it matter?

Quote
If tempVal is not 0, how can it be anything other than not 0? The 2nd if statement should be an else.
This what always confuses me. the logic of if's and else's. I cant figure it out smiley-sad
3  Using Arduino / Programming Questions / Re: hold last sensor value on: December 13, 2012, 10:02:00 am
I was wondering about that. How fast a hardware pulldown occurs VS how fast the arduino loops. But it behaves ok. So if it isn't broken don't fix it, right?

Now that that works I need to figure out how to release it so that I can slide my finger over the ribbon triggering notes form a scale.

I am currently blocking the polling of the sensor by how I wrote my code so the value does not update and the note won't change. Can you point me in the right direction please?

Code:
#include <MIDI.h>

int posPin = A0;
int posVal = 0;
int note = 0;
int tempVal = 0;
int led = 13;
int scale[] = {
  60,62,64,65,67,69,71};

#define LED 13

void setup() {
  pinMode(LED, OUTPUT);
  MIDI.begin();            // Launch MIDI with default options
}

void loop(){
  readPos();
}

void readPos(){
  tempVal = analogRead(posPin);

  if(tempVal == 0) {
    MIDI.sendControlChange(123,0,1); // OMNI NOTE OFF MSG
    digitalWrite(led, LOW);
  }

  if(tempVal !=0) {
    posVal = tempVal;
    posVal = map(posVal, 1023, 1, 127, 0); // make midi notes
    posVal = constrain(posVal, 0, 127); // constrain it
    note = map(tempVal, 1023, 1, 6, 0); // make it 7 for the note array
    note = constrain(note, 0, 6); // constrain it
    note = scale[note]; // pick a note
    MIDI.sendNoteOn(note,127,1); // send the note (note, velocity, channel)
    digitalWrite(led, HIGH);
  }
}
 

4  Using Arduino / Programming Questions / Re: hold last sensor value on: December 13, 2012, 09:19:50 am
Code:
    delay(30);
So, you DID mean periodically? You swore up and down you didn't.

the delay was just in there to slow things down temporarily

 smiley-small
5  Using Arduino / Programming Questions / Re: hold last sensor value on: December 13, 2012, 06:47:50 am
Yes do you mean something like this:-
Code:
tempVal = analogRead(posPin);
if(tempVal !=0) posVal = tempVal;

yey! this works:

Code:
void loop(){
    delay(30);
    readPos();
    MIDI.sendControlChange(22, posVal, 16);
}

void readPos(){
  tempVal = analogRead(posPin);
  if(tempVal !=0) {
  posVal = tempVal;
  posVal = map(posVal, 1023, 1, 127, 0);
  posVal = constrain(posVal, 0, 127);
}
}

6  Using Arduino / Programming Questions / Re: hold last sensor value on: December 13, 2012, 06:15:15 am

Hey, since I have a reliable zero (pull-down R) when not pressed. It must be possible to "hold" any last value that wasn't a zero, no?
7  Using Arduino / Programming Questions / Re: hold last sensor value on: December 12, 2012, 12:40:45 pm
I hear ya.

thanks!
8  Using Arduino / Programming Questions / Re: hold last sensor value on: December 12, 2012, 10:24:30 am
So, you want it to detect the highest value read within some period of time? Remember that the 0 values that it reads are perfectly valid values. Remember also that it will read values from zero up to some high value and then all the way back down to zero.

If I press 0 that would indeed be the right value for that case. However, I would like it to continously send the last value I pressed circumventing the automatic drop back to 0.

I am building a midi instrument and I am using the position sensor to update filter parameters. Kinda dull if it always snaps back to zero. It should just stay where I last lifted my finger.

cheers
9  Using Arduino / Programming Questions / Re: hold last sensor value on: December 12, 2012, 09:59:59 am
Quote
I need it to stay on the last value it read.
That's exactly what it is doing. The last value that it read was a 0. You need to be a little clearer in your requirements.

Sorry if I was unclear,

Its a 50 cm position sensor and if I press it in the middle and get a value of perhaps 60, I would like the MIDI.sendControlChange to keep sending 60. Until I press again somewhere else and update the "last pressed value".


Thanks
10  Using Arduino / Programming Questions / hold last sensor value on: December 12, 2012, 09:28:19 am
hello

I would like to loop the last value coming out of a pressure sensor. At the moment the value drops back to 0 when no pressure is applied because it is a resistor. I need it to stay on the last value it read.

It is probably easy but I can't figure it out.

Code:
#include <MIDI.h>

int posPin = A0;
int posVal = 0;

void setup() {
 MIDI.begin(4);
}

void loop() {
  delay(30);
  posVal = analogRead(posPin);
  posVal = map(posVal, 1023, 0, 0, 127);
  posVal = constrain(posVal, 0, 127);
  MIDI.sendControlChange(20, posVal, 4);
}

Thank you!

Fubbi
11  Using Arduino / Project Guidance / Re: LED strip power consumption on: June 29, 2012, 09:23:28 am
Ok I have a plan, thanks!

fubbi
12  Using Arduino / Project Guidance / Re: LED strip power consumption on: June 29, 2012, 04:58:48 am
 I won't run anything at 100% and never all LEDs at the same time.

would this do it?
5V 20A 100W, MeanWell SP-100-5
http://www.hed-radio.com/de/Netzteil-SP-100-5.html

Again, I have 33 x 60cm strips in series. So how often do I need to power them, every 5m? that would mean 4 or powerpoints.

fubbi
13  Using Arduino / Project Guidance / Re: LED strip power consumption on: June 28, 2012, 11:20:24 am
Yes, split them up as there is no way you can get 40A through the first strip.

So how much can the strip take? I need to find a small outdoor power supply, or can I use a big one and somehow portion out the power?
Is there a way to divide a 20A output to 10x2A outputs?

thanks

fubbi
14  Using Arduino / Project Guidance / Re: LED strip power consumption on: June 28, 2012, 11:04:56 am
So I need several smaller power sources along the way?

fubbi
15  Using Arduino / Project Guidance / LED strip power consumption on: June 28, 2012, 10:28:33 am
I am about to work with 33 x 60 cm strips of this kind:
http://www.ladyada.net/products/digitalrgbledstrip/index.html

the strips will be connected in series and I am wondering how much power I will need

it states:

"Maximum 5V @ 120mA draw per 2.5" strip segment (all LEDs on full brightness) - about 2A per meter"

does that mean I need 2A x 20 Meter = 40A???

sounds like a lot...

Fubbi

Pages: [1] 2 3 ... 10