Show Posts
Pages: [1]
1  Using Arduino / Audio / Re: ARDUINO + musical instrument shield to make a Keyboard on: October 08, 2012, 04:02:11 pm
Hi Duane,

My keys are simple switches... then, as you guessed, the Arduino send midi data to the shield to play notes.
Regarding your case, have you take in consideration the possibility to connect a PS/2 keyboard to your Arduino, using the appropritate library ?

2  Using Arduino / Audio / ARDUINO + musical instrument shield to make a Keyboard on: October 08, 2012, 05:54:45 am
Hello world  smiley

After searching for hours a way to make a keyboard from Arduino and MI shield from sparkfun, and with the helps of few people, I finally get my program.
It will probably seems a bit simple for advanced users, but It was quite a lot of work for me to make it works as a beginner. I thought it could be great to save time for other beginners if I share this program in this topic, so here we go , but before, if advanced users have some suggestions to improve it, you are more than welcome to contact me as I'm waiting to learn more :

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //Soft TX on 3, we don't use RX in this code

int inputPins[] = {5,6,7,8,9,10,11,12,13};
int note[]={72,74,76,77,79,81,83,84,86};
int pinCount = 9;

int buttonState[9];
int lastButtonState[9]; 

byte resetMIDI = 4; //Tied to VS1053 Reset line
int instrument = 13;

void setup() {

  //Setup soft serial for MIDI control
  for(int i=0; i<pinCount; i++){
  pinMode(inputPins, OUTPUT);//pinMode(outputPins, OUTPUT);
  digitalWrite(inputPins, LOW);// this enables the pull up resistors to reduce noise
  pinMode(inputPins, INPUT);

  //Reset the VS1053
  digitalWrite(resetMIDI, LOW);
  digitalWrite(resetMIDI, HIGH);
  talkMIDI(0xB0, 0x07, 126); //0xB0 is channel message, set channel volume to near max (127)
  talkMIDI(0xB0, 0, 0x79); //Default bank GM1
  talkMIDI(0xC0, instrument, 0); //Set instrument number. 0xC0 is a 1 data byte command


void loop() {
for (int i=0; i<pinCount; i++){

  buttonState = digitalRead(inputPins);
  if (buttonState != lastButtonState) {       
    if (buttonState == HIGH) {                     

  lastButtonState = buttonState;

//Send a MIDI note-on message.  Like Pressing a piano key
void noteOn(byte channel, byte note, byte attack_velocity) {
  talkMIDI( (0x90 | channel), note, attack_velocity);

//Send a MIDI note-off message.  Like releasing a piano key
void noteOff(byte channel, byte note, byte release_velocity) {
  talkMIDI( (0x80 | channel), note, release_velocity);

//Plays a MIDI note. Doesn't check to see that cmd is greater than 127, or that data values are less than 127
void talkMIDI(byte cmd, byte data1, byte data2) {

  //Some commands only have one data byte. All cmds less than 0xBn have 2 data bytes
  //(sort of:
  if( (cmd & 0xF0) <= 0xB0)


Here is a link to see it working :

I also wrote the program to have this keyboard working with the Touch pad shield from Sparkfun. If people are interested , don't hesitate to ask.

All the best,


3  Forum 2005-2010 (read only) / Interfacing / Re: Dim LED with level Sensor on: October 19, 2010, 08:22:28 pm
Dear Paul,

Sorry to come back to you so late  smiley-sad
Processing is fantastic, from that I was able to adjust the map value and make the sensor work.
Next step, being able to connect it to a Velleman K8064 to dim a 12V halogen bulb.
So exciting...
Will keep you updated and thank you so much for your advice.
4  Forum 2005-2010 (read only) / Interfacing / Re: Dim LED with level Sensor on: October 10, 2010, 06:30:10 pm
Hi Paul,

Following your advice, I've tried to understand how to use the 'serial' function, but all tutorials are explaining different things so I'm not really sure about what to add exactly into the code.

I will try to experiment this overnight, and will let you know the result, ... if I have one  :-/

Anyway, I have to say, having problems is a really good way to discover things.

Thanks again.
5  Forum 2005-2010 (read only) / Interfacing / Re: Dim LED with level Sensor on: October 10, 2010, 07:18:06 am
Dear Paul,

Thank you for your answer. Basically, I'm trying to measure value of V according to how it's changing due to the sensor resistance. But Again I'm a novice and I've done it the wrong way.

What I'm aiming is the change of the resistance value of the sensor and then change it as a value I can use to change LED brightness.

I thought the photosensor was also acting as a resistor, so its action was exactly the same as my level sensor, that's why I ve just exchange both.

Is the circuit I'm using as a reference is not the good one ?
6  Forum 2005-2010 (read only) / Interfacing / Re: Dim LED with level Sensor on: October 10, 2010, 05:57:59 am
Hi Paul,

I've used the scheme which is in a beginner exercise to dim an LED with a photosensor.

you can see that ircuit on that website:

I've just replaced the photosensor with my level sensor.

I've used the same programm as it was working really well with the photosensor.

I also had a reply from the company whose making the sensor and they said maybe it's the value of the resistor which is a problem.

I'm lost but again, still trying...
7  Forum 2005-2010 (read only) / Interfacing / Dim LED with level Sensor on: October 09, 2010, 03:47:11 pm
Hi everybody,

Just get an Arduino and enjoyed it so much. My pleasure for tonight, my first post on the Arduino family forum.

I'm trying to dim an Led according to the circuit explain below:

LED connected to pin 9 and have a 560 ohms resistor before ground
Sensor is connected to 5V pin, and have a 10Kohms resistor before ground, and a connection to analog pin 0

Below the specs of my level sensor:

Power requirements: Up to +5 VDC
Communication: Resistive Output
Sensor Output: 550 ohms empty, 60 ohms full, ± 20%
Resistance Gradient: 40 /inch (16 /cm), ± 20%

I've tried to changed the value of the resistor connected to my sensor, but nothing is happeing, brightness is still fix.

Below is the code I've used:

[glow]//Level Sensor Pin
int levelPin = 0; //the analog pin the level sensor is
                  //connected to
                  //the level sensor is not calibrated to any units so
                  //this is simply a raw sensor value (relative level)
//LED Pin
int ledPin = 9;   //the pin the LED is connected to
                  //we are controlling brightness so
                  //we use one of the PWM (pulse width
                  // modulation pins)
void setup()
  pinMode(ledPin, OUTPUT); //sets the led pin to output
* loop() – this function will start after setup
* finishes and then repeat
void loop()
int waterLevel = analogRead(levelPin); //Read the
                                        // waterlevel
waterLevel = map(waterLevel, 0, 900, 0, 255);
         //adjust the value 0 to 900 to
         //span 0 to 255
waterLevel = constrain(waterLevel, 0, 255);//make sure the
                                           //value is betwween
                                           //0 and 255
analogWrite(ledPin, waterLevel); //write the value

I'm a novice in programming and electronic, so I'm sure I did it wrong.
I'm still trying different programs, and circuits, but start to be a little bit afraid of what could happen (an explosion maybe ??  smiley-wink )

I'm more than open to any suggestion, even if you have to tell me that I'm a dum, as I will agree.

Thanks a lot in advance,
I'm going back to my water circuit  smiley-grin

Pages: [1]