Go Down

Topic: reading and writing pins (Read 363 times) previous topic - next topic

wilykat

I'm trying to build an interface using Arduino to read Atari Jaguar controller.  I have the details since there's no library for this controller.  It's a bit of a weird key pad matrix with 1 button using all 4 columns while the numeric buttons are 1 per column. I tried using keypad library but it wasn't working well to Jaguar's odd design so I wanted to try my own scheme.

I could use read to variable, then write variable but that seems to take more space.  Is there a way to do something like this:
digitalWrite(yy) the value of digitalRead(xx) (straight write what is read)  If this can be done, it'd be one line instead of 3 or 4 lines per button.

The experiement will use Mega2560 to control 21 LEDs, each one will light up when I press a specific button.  I have pile of Jaguar controller and no Jaguar system to test with.  A working Jaguar with 1 game is almost $100 on eBay plus I'd have to wait about a week and hope I didn't get bummed by a dishonest seller, a mega clone is about $20 which I already have and I could finish this tonight.

ijm51000

Hi

Bit of hard work, start with a mulitmeter and map the pins, that is where I would start.

Each button one by one, on the keypad, going along the pins and map the key presses, once that is mapped out, it should be easier to see where you are going.

All the best

Ian

BillHo

#2
Apr 21, 2013, 06:47 am Last Edit: Apr 21, 2013, 07:06 am by BillHo Reason: 1
Quote
The Jaguar pad is basically four sets of buttons. Three of those sets have five buttons, and the fourth has six. Each set has one pin that is pulled low to read the buttons within that set on five (or six) other pins. It is useful to think of the Jagpad as a matrix of twenty-one buttons.


Each of the four column pins is pulled low one at a time, and any buttons in that column that are pressed will cause a low signal to appear on its corresponding row pin.

Pinout

High-density 15-pin male D-sub connector on the controller.


1.  /Column 1 address (option, 3, 6, 9, #)
2.  /Column 2 address (C, 2, 5, 8, 0)
3.  /Column 3 address (B, 1, 4, 7, *)
4.  /Column 4 address (Pause, A, N, S, E, W)
5.  -
6.  Row 1 data (pause)
7.  +5VDC Source
8.  -
9.  GND
10.Row 2 data (A, B, C, Option)
11.Row 3 data (E, 1, 2, 3)
12.Row 4 data (W, 4, 5, 6)
13.Row 5 data (S, 7, 8, 9)
14.Row 6 data (N, *, 0, #)
15.-

http://emu-docs.org/Jaguar/Controllers/jagcont.html
So you need 10 pins, 4 output and 6 input to read the key pad matrix.

Code: [Select]
#include <Keypad.h>

/*
Pause
A B C Option
East 1 2 3
West 4 5 6
South 7 8 9
North * 0 #
*/

const byte ROWS = 6; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'P','P','P','P'},
  {'A','B','C','O'},
  {'E','1','2','3'},
  {'W','4','5','6'},
  {'S','7','8','9'},
  {'N','*','0','#'}
};
byte rowPins[ROWS] = {7, 6, 5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {11, 10, 9, 8}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
}

void loop(){
  char key = keypad.getKey();

  if (key != NO_KEY){
    Serial.println(key);
  }
}



wilykat

I already have the pinout details: http://emu-docs.org/Jaguar/Controllers/jagcont.html  The controller has an IC inside which is probably why the keypad library isn't working right.  keypad library is meant to be used with "dumb" keypad and not one in controller.

I wanted to know if there's a neat way to make it write output based on the pin input from Jaguar controller.  If I write the code that way:
if input = high
digitalwrite output high
else
digitalwrite output low

I wanted to shrink that 4 lines to something smaller and neater looking but arduino isn't accepting my attempt to write the data from read on the same line. I probably didn't format the command correctly, if it is possible.

UKHeliBob

Code: [Select]
digitalWrite(outputPin, digitalRead(inputPin));
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

wilykat

Thanks!!! That's what I needed! I now see what I did wrong with my earlier attempt.

Go Up