Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

input and save input

Status
Not open for further replies.
You don't got have wpu you can use a 50 k resistor and do the samething just more parts.
 
what Pommie has posted, one bit at a time.
PortB wpu's are enabled and portC are cycled LOW (portC.bits(x)= 0) All portC ports are HIGH then scanned LOW.
Good idea but it doesn't work. I assumed you'd enable the portB pullups.

HINT: when the portC pin is low and the switch is pressed is the diode forward or reverse biased?
Does it conduct? If it doesn't conduct what would the portB pin it's connected to see?

On the above matrix diagram - swap the ports
How about just wiring things correctly? That'll work too. That way you won't have to swap port direction to turn on the led.

But please, save us the anguish and just use a bigger chip. Please.
 
Last edited:
As I said in an earlier post, "never going to happen".

It's all doable but not until 30 pages of posts and no conclusion. I'll be proved right in about 6 months.

Have fun.

Mike.
 
Am getting some progress but very little.
YES still have not eliminated the larger pic.
What advantage to swapping ports? PortC.(x) = LOW, pressing switch PortB.(x) goes LOW
 
If you use portb you can read the switches using the pullups to make it high the pullups are like 50 kohms and don't light the leds.

But as said you got first make the layout of the leds and switches right first.

You would be better using a adc pin to read 8 to 12 buttons on a ladder very simple and would work great with a game they been making games that way for years.
 
PortC.(x) = LOW, pressing switch PortB.(x) goes LOW
I assume you're still using the schematic shown in mexi-trainmatrix.jpg from post #71.
Probably a bad assumption on my part but that's all I've got to work with.

Assuming you have the portB(x) pin pulled high, when the switch is NOT pressed you'll read a high
on the portB(x) pin from the pullup when the PortC(x) pin is either high or low. So far so good.

Now, set portC(x) = 0. Press the switch. The diode now has 0V on the positive side and +5V from the pullup on the negative side.
That's called reverse-biased... the diode doesn't conduct. So as far as the matrix is concerned you could just pull it
out of the circuit. What's on the portB(x) pin? The 5V from the pullup, so the portB(x) pin again reads high.

As shown the portB pins can NEVER read low (unless you decide to start writing to the input ports again).

Once you get the matrix stright, you do realize that at the same time you're scanning the keys you'll have to scan the LED outputs as well,
right? If you start adding the typical "delayms(500)" calls the LEDs are going to blink all over the place.


It's all doable but not until 30 pages of posts and no conclusion
That might be overly optimistic, Mike. I'm figuring 20-30 pages just to get the switches scanned. Then, lighting the leds will take...
 
I totally neglected the reverse biased on the diodes. Need to reconsider.
Yes realize the leds will be blinking. Taking one step at a time but this switch matrix idea is intriguing at best,
I am leaning towards going with the bigger chip, take my time and learn how to solder the smaller footprint.
news at 11
 
As a fun exeecise and as part of your quest for knowledge, can you wxplain how to read a switch matrix?
 
Weak pullup is around 50 k it can't light a led but I would go for a ladder and adc pin coding be a lot easier.
 
to deal with blinking leds and other issues IMO the easy solution is to go with the larger pic and possibly have two matrix's, one for Leds and one for the switches for a total of 14 port pins ( 2 - 2 x 5 matrix).
designed a schematic with no matrix's and am seeing small issues arising already.
 
I think I have a switch matrix code figured out? Just need to breadboard. Was looking at using pbyte(x).bits(y)??
[

WHILE true
FOR x = 0 TO 4 //SET ALL PORTB BITS TO LOW and portC to high due to the bias on the diodes
portc.bits(x) = 1
portb.0 = 0 //first 5 switches
IF portb.0 = 1
THEN
Player(x) = 1 //When portC makes a switch on port B high this designates
END IF // the player that depressed their button only first 5 switches 0 to 4
NEXT

FOR Y = 0 TO 4 //SET ALL PORTB BITS TO LOW and portC to high due to the nias on the diodes
portc.bits(x) = 1
portb.1 = 0 // next set of 5 switches
IF portb.1 = 1
THEN
Player(x) = 1 //When portC makes a switch on port B high this designates
END IF // the player that depressed their button. only second 5 switches 5 - 9
NEXT
WEND

/QUOTE]
 
I was joking about writing to the input pins. Please don't write to portB. Remove the diodes.
 
I was joking about writing to the input pins. Please don't write to portB. Remove the diodes.

"It's right there. Tumbleweed said it was ok to write to input pins!!!"

MrDEB has a remarkable ability to only see what he wants to.
 
"If portb.0 = 1" Guess he still don't no that's saying it's a 1
== 1 is a test for 1 the = 1 your'll get a 1 even if it's a 0
 
"If portb.0 = 1" Guess he still don't no that's saying it's a 1
== 1 is a test for 1 the = 1 your'll get a 1 even if it's a 0
Hi Burt,

That's only in C. Swordfish just uses a single equals for comparison.

mike.
 
I put the portB.0 =1 to be sure it IS HIGH
nothing wrong with guaranteeing it is the desired logic level that you want?
Going with a 2 x 5 mayrix for the switches, a 2 x 5 matrix for the LEDs
IMO it makes this projects code simplified.
Now to get back to saving player positions.
If players are at portC.0,2,4,5,7,9
how do I INPUT and save the player positions to enable their LED when it's their turn to play?
 
I put the portB.0 =1 to be sure it IS HIGH
nothing wrong with guaranteeing it is the desired logic level that you want?
It's a freaking input pin. You CAN'T write to it (well you CAN but it's not doing what you think it is).

If you want to ensure it's high then arrange your hardware to assert it high.
 
It's a freaking input pin. You CAN'T write to it (well you CAN but it's not doing what you think it is).

If you want to ensure it's high then arrange your hardware to assert it high.

What ha says ^^^. If people who know what they are doing ALL tell you what you are doing is wrong, perhaps you need to get a fricking clue and figure it out.

I explained a number of ways to know which players are active year ago when this first started. Use a VARIABLE in any of several ways. There is no reason to store it in EEPROM or do anything other than using a VARIABLE.

Switches and LEDs in matrices using a 40 pin chip is plain old stupid, expecially since you don't understand how to do it.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top