Show Posts
Pages: 1 [2] 3
16  Forum 2005-2010 (read only) / Frequently-Asked Questions / sparkfun 4x4 keypad matrix on: October 29, 2006, 12:44:27 pm
I was looking through the  sparkfun website and found these keypad matrices....

which allow each button to be individually lit by an led. i've decided to use a keypad encoder to limit the number of pins i need to use to run it, so i have a couple of 74C922 keypad encoders on order from Farnell. heres the data sheet

the idea is that the 74C922 ic reads the key pad matrix, and when a button is pressed, it sends a logic signal via the data pin to the arduino, which tells the arduino to read the four input pins from the 74C922 and to save these inputs as a 4 digit binary number. this 4 digit binary number relates to one of the 16 buttons on the keypad.

so far i have written this code, that reads the data pin, and if its HIGH, then it switches on an led on pin 13, and then reads the input pins and prints the data to the serial connection.

int dataPin = 2; // data pin
int in1Pin = 3; // input pin 1
int in2Pin = 4; // input pin 2
int in3Pin = 5; // input pin 3
int in4Pin = 6; // input pin 4
int ledPin = 13; // led pin
int val = 0;

void setup() {
  pinMode(dataPin, INPUT); // declare pins as input or output
  pinMode(in1Pin, INPUT);
  pinMode(in2Pin, INPUT);
  pinMode(in3Pin, INPUT);
  pinMode(in4Pin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600); // begin serial

void loop() {
   val = digitalRead(dataPin);  // read data pin value
  if (val == HIGH) {  // if HIGH
  digitalWrite(ledPin, HIGH);     // switch on led pin  
    digitalRead(in1Pin); // read inputs
    Serial.print(in1Pin, BYTE); // print inputs to serial connection
    Serial.print(in2Pin, BYTE);
    Serial.print(in3Pin, BYTE);
    Serial.print(in4Pin, BYTE);
  } else {
    digitalWrite(ledPin, LOW); // if data pin LOW, switch off led pin, and do nothing.

it complies fine, but is so far untested as i dont have the parts yet. what i would like to do is to hold the 4 digit binary number as a string, then print to the serial port. at the moment i think this code will print each input byte individually, but i dont really understand how to store it as a string just yet.

so, any comments or ideas to make it run smoother?


17  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: 'midi in" project.... on: August 24, 2006, 06:52:37 am
i got this circuit working recently with a pic to see if it was an issue with the parts i was using but it wasnt, so still no joy on the arduino side of things.  smiley-razz
18  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: 'midi in" project.... on: July 13, 2006, 05:46:20 am
oops, that was a typo!

tried flipping the connections loads of times, i'm going to rebuild it all from scratch this week end and see if it helps.  >smiley-sad
19  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: 'midi in" project.... on: July 10, 2006, 02:13:07 pm
right, i removed the chip, connected the midi device and the board together, plugged the board into the usb port, opened terminal and set up as per required to listen to serial communication, and still nothing. think i may have a hardware problem, as woo_oow seems to have got it working.

i'm using:

220R 1/4 watt resisitor
270R 1/4 watt resistor
1n194 diode
6n138 opticoupler darlington output.

all the parts came from, maybe i bought something incompatible..... :-?

cheeers for the tips so far guys, back to the drawing board.
20  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: 'midi in" project.... on: July 09, 2006, 02:14:47 pm
typical! dont you just hate it when you run out of usb cables......  >smiley-sad

i'll give this a shot when i get back from work tomorrow armed with a couple of extra cables! i've set up Terminal in OSX to listen to incoming serial data, so it should be able to tell me whats coming in, or not as the case maybe.

21  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: 'midi in" project.... on: July 09, 2006, 02:01:14 pm
ah, cunning!

so if the atmega8 chip isnt there, will the board route the signal from the rx pin through to the usb connector?

i'll give it a go anyway.

22  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: 'midi in" project.... on: July 09, 2006, 07:54:03 am
to be honest i didnt expect that code to work anyway for the same reason that val is only one byte, not a string of bytes.

my main problem at the moment is to actually receive any sort of signal from the rx pin. when i connect the circuit up, the rx and tx leds on the board dim to half their brightness, and there seems to be no signal at all being recieved by the board when i send a midi note from the midisport interface. maybe i've screwed up the hardware side of things, but i've checked it a million times.  :-?

i used to use MAX to convert midi notes to ascii characters to send over to the arduino board to activate reed relays, but i'm sure there must be a way to get arduino to do this itself.

think i'll go and bang my head against the wall a bit more.....
23  Forum 2005-2010 (read only) / Frequently-Asked Questions / 'midi in" project.... on: July 08, 2006, 05:34:57 am

i've been working on this project for a month or so now, and not really getting anywhere with it. in the past i've mainly used my arduino board for LED control and for switching reed relays on and off, but now i'm trying(unsuccessfuly) to get arduino to listen to incoming midi messages from an external sequencer.

having looked arround the web, i've decided to use a common schematic that is also available from Toms site.

its the top schematic, for midi in.

i have a bread board with the parts set up, and the serial out from the 6n138 chip is connected to the RX pin of my arduino board.

at the moment, all i'm trying to do is get the board to listen for a midi signal and switch on pin 13, where i have an led connected, but so far its just not working.

i have tried loads of different variations of code, heres an example, which was modified from the basic serial read tutorial.

int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the data from the serial port

void setup() {
  pinMode(ledPin,OUTPUT);   // declare the LED's pin as output
  Serial.begin(31250);        // connect to the serial port

void loop () {
  // read the serial port
  val =;

  if (val != -1) {
    if (val == 0x90, 0x01, 0x45 ) { // note on, channel 1, note value 1, velocity 45
      digitalWrite(ledPin, HIGH);
      digitalWrite(ledPin, LOW);

i have a midi signal being sent from ableton live, through my usb midisport 2x2 and into the bread board. from there it goes through the 6n138(and the relevant diodes and resistors) to the RX pin of the arduino board. the board isnt connected via usb, and is powered from a wall adaptor.
the RX and TX leds on the board are lighted up(but very dim) but i just cant seem to get any sort of response. i can see that the Midisport is receiving the signal from ableton as its got indicator leds to show when a signal is received and sent.

so, does any one have any ideas or tips that might get this working? it would be greatly appreciated!!


24  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: audio input to pwm on: January 19, 2007, 07:26:04 am
thanks for the tips on the passive RC filters daniel! its appreciated.
the intention of the project is not to make a colour organ but its the effect that i'm hoping to produce, as i'm using the led to indicate that the code and frequency imputs work, before implementing the idea into yet another project, that requires sound to drive motors and relays.

i was playing arround with filter circuits this morning, but really could do with an osciliscope to make sure its right.


bod. smiley-grin
25  Forum 2005-2010 (read only) / Frequently-Asked Questions / audio input to pwm on: January 18, 2007, 01:31:26 pm
Hello peeps! been a while since i posted on here!

anyway, i'm about to start work on a project based on the tutorial about led colour mixing with 3 potentiometers )this one ).

basically i intend on taking an audio signal and split it into bass, middle and high frequencies using some simple filter circuits. with these three frequencies connected to the analogue inputs instead of the potentiometers, i hope to drive the rgb led in time with the music, like an old colour organ.

has anyone tried this sort of thing before? i havent got the parts yet, but i'm not sure if i'll need to amplify the audio signal with an LM386 ic.


26  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Arduino with Max/MSP? on: May 04, 2006, 10:17:16 am
its actually very simple, but you need to make sure you have the serial usb drivers installed first. are you using a mac or a pc? i'll post up my patch over the weekend for you.
27  Forum 2005-2010 (read only) / Frequently-Asked Questions / question for all you MAX7219 users... on: May 01, 2006, 06:01:39 am
i've been using the Nexus Machines LED matrices with Arduino, that have the MAX7219 chip built into it, but now i'm building my own, and i cant find any details on whats the maximum specs of LEDs you can use with the chip. i need them to be as bright as possible while still working on 5volts from the arduino board.

i've checked through the data sheets a million times and cant seem to find anything. am i just blind or what?  :-?


28  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: mac problems on: April 11, 2006, 08:21:32 am
i havent uploaded anything to the board as yet, i only upgraded to 10.3 (panther) last night, but i loaded a program into the IDE and it compiled ok, with no error messages, so i recon that should do it.
29  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: mac problems on: April 11, 2006, 07:58:04 am
i had the same problem, which is that the arduino software cant access some of the libraries on 10.2...... i think mellis or someone was looking into it, but i just upgraded to 10.3 instead.

hope this helps.

30  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: how to controll brightness of LEDs with max 72 on: March 17, 2006, 04:04:30 am
i wasnt aware that the 7219 could dim individual leds at all. thats interesting! but then my display incorporates 12 of the chips so thats going to be a nightmare... think i'll just stick with what i (vaguely) understand for the time being.  ;D
Pages: 1 [2] 3