Using CMOS IC and Mega2560 on a 5v system

Mega2560 is designed for 3.3v operation and CMOS generally can run on wide range of voltage without any issue but my concern is that the switched pins of 4066 would be handling 5v. I wanted to use Mega2560 with touch screen LCD to replace an existing keypad on an older gaming controller (Atari 5200 specifically) and I was wondering:

Should I

  • wire 4066s VCC to 3.3 power source, the switch control pin (5, 6, 12, and 13) to ATMega and the 5v to in/out of each switch to console
    OR
  • wire 4066 VCC to 5v source, the switch control pin via pullup resistor to 5v and to ATMega with internal pullups turned off, and the in/out of each switch to console
    or is there something else?


typical 4066 pinout. Atari 5200 uses 3x4 wiring matrix to the keypad but I wanted to use LCD with SD card slot so I can load game specific overlay image.

wilykat:
Mega2560 is designed for 3.3v operation...

Is it?
My Mega is running on 5volt, and I don't know of any 3.3volt versions.

Seems you aked for a solution to the same problem here.
https://forum.arduino.cc/index.php?topic=493553.0

Consider optocouplers. One for each button.
Leo..

LCD and SD card are 3.3v and I was under mistaken belief that Mega is 3.3v for that reason but if it is 5v then my original question is no longer valid, no voltage difference to deal with.

There are quad optocouplers that I could use and it's not much more than 4066s. I don't know if optocoupler are bidirectional or not. Analog switch CMOS are bidirectional. OTOH optocoupler are isolated.

I'd have to start poking into my 5200 and see if the current flows only from one side (ie only colums) and scans other sides (ie rows) and then orient the optocouplers. Should the collector side be aimed at active signal and emitter on other side that reads which button was pressed?

wilykat:
Should the collector side be aimed at active signal and emitter on other side that reads which button was pressed?

I assume the switch/contact has a positive and negative side, even when scanned.
Just connect the opto transistor collector to the positive side, and emitter to negative.
1mA opto LED current should be enough, assuming the transistor/switch current will be much less than that.
Leo..

With the Atmel ATmega chips like the 328 and 2560 if the board runs at 16MHz, it'll be 5V as the
chips aren't spec'd for more than about 10MHz clock at 3.3V, and for instance the ProMini 3.3V model
is 8MHz due to this.

There are various ways to level shift between 3.3V and 5V which hopefully are covered in many searchable
threads here should you need them.

With common grounds and both systems 5V no isolation/level-translation is needed of course.

Wawa:
I assume the switch/contact has a positive and negative side, even when scanned.
Just connect the opto transistor collector to the positive side, and emitter to negative.
1mA opto LED current should be enough, assuming the transistor/switch current will be much less than that.
Leo..

The keypad is read one column at a time. One of column is pulled low, then any buttons in that column that are mashed are read as low signals on row.

Seems to me that row pins are held high via pullup resistor and the column are also held high unless it's being scanned, then it's low. So collector on rows and emitter on column?