Coder Social home page Coder Social logo

Comments (2)

BrendanSimon avatar BrendanSimon commented on September 9, 2024

Hi. The membrane keypad I was using is very similar to these.

https://www.ebay.com.au/i/133024948873

Not sure about the error. I've never used EPS devices.

Which file are using exactly?

https://github.com/BrendanSimon/micropython_experiments/blob/master/keypad/keypad_timer.py

It might be related to these issues. Looks like the Pin object needs to have pin numbers, instead of strings (str). I'm guessing that's a difference in API between pyb and machine.

https://www.tutorialfor.com/questions-289240.htm
micropython/micropython-esp32#33

from micropython_experiments.

mraess avatar mraess commented on September 9, 2024

Hey,

Thanks for the reply here! I was able to implement a much simpler solution, which I got from https://www.raspberrypi.org/forums/viewtopic.php?t=211657, which I re-wrote to work on the esp8266/esp32.

My only problem now is that the code works locally when my MAC is connected to the machine in upyCraft - all keys get recognized by themselves (the only change I made to the wiring is I put in diodes to suppress potential ghosting) - It works even as a 1x1 or 1x2 matrix. However, when the code is in stand-alone mode with only power connected, the script isn't executing like it is when the board is connected.

from machine import Pin
import time

led = Pin(2, Pin.OUT)

matrix = [1, 2, 3, 4]
        
	
COL = [5, 12]
ROW = [0, 14]

for j in range(2):
            #machine.Pin(COL[j], machine.Pin.OUT)
            Pin(COL[j], Pin.OUT).value(0)
            print("COL = ", Pin(COL[j]).value())
            
for i in range(2):
          Pin(ROW[i], Pin.IN)
          print("ROW =", Pin(ROW[i]).value())
          
 
while True:
    for j in range(2):
        
        Pin(COL[j]).value(1)
        for i in range(2):
            if Pin(ROW[i]).value() == 1: 

                print ("col = ",(j+1))
                print ("row = ",(i+1))

                m = ((i * 2) + j)
                print ("postion = ",(m))
                print ('button = ', matrix [m])                
                time.sleep(0.1)
                
                while Pin(ROW[i]).value() == 1:
                    led.on()
                    time.sleep (0.2)
         
        led.off()
        Pin(COL[j]).value(0)

Sample output when board is first connected - then in REPL/upyCraft I get the below outputs when I press them.

COL =  0
COL =  0
ROW = 0
ROW = 0

Button 1 pressed

col =  1
row =  1
postion =  0
button =  1

Any ideas are of course welcome. I believe I have to wrap the whole thing in a function and somehow store the key_index or something.

from micropython_experiments.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.