Pin out Matrix creator

Hello I would like to make this script work for my matrix creator but I am a little lost in the pins I would need help thank you :slight_smile:
`

coding=utf-8

import Ext.GPIO as GPIO
import time
import sys
GPIO.setwarnings(False)
# définition des variables
pin1=19
pin2=18
pin3=27
pin4=22
# définition des broches
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin1,GPIO.OUT)
GPIO.setup(pin2,GPIO.OUT)
GPIO.setup(pin3,GPIO.OUT)
GPIO.setup(pin4,GPIO.OUT)
# définition des variables
Apin1=[0,1,0,0,1]
Apin2=[0,1,1,0,0]
Apin3=[0,0,1,1,0]
Apin4=[0,0,0,1,1]
current=0
target=0
print "Programme test Moto2 [Appuyez sur Ctrl + C pour terminer le test]"

# définition de la fonction
def GO_THERE(target,current):
	if current<target:
		while current<target:
			i=current&2 + 1
			GPIO.output(pin1,Apin1[i])
			GPIO.output(pin2,Apin2[i])
			GPIO.output(pin3,Apin3[i])
			GPIO.output(pin4,Apin4[i])
			time.sleep(.003)
			current= current + 1
	else:
		while current>target:
			i=current&2 + 1
			GPIO.output(pin1,Apin1[i])
			GPIO.output(pin2,Apin2[i])
			GPIO.output(pin3,Apin3[i])
			GPIO.output(pin4,Apin4[i])
			time.sleep(.003)
			current= current - 1
	print current,target
	return current;
# programme principal
try:

	while True:
		target=1000
		current=GO_THERE(target,current)
		
		time.sleep(2)
		target=0
		current=GO_THERE(target,current)
		
		time.sleep(2)
		target=2000
		current=GO_THERE(target,current)
		
		time.sleep(2)
		target=0
		current=GO_THERE(target,current)
		
# remise en place de tous les GPIO
except KeyboardInterrupt:
	GPIO.cleanup()`

Hi @Latos,

From the code it seems the pins defined are digital pins. In that case, you could use the MATRIX Lite Py GPIO library instead of the Ext.GPIO library, so you would have to modify the code.

The reason you need to use a MATRIX library instead is that the MATRIX Creator uses up the Raspberry Pi pins used by that Ext.GPIO library for other functions and so you would have to use the MATRIX Creator’s expansion GPIO pins.

Here is the setup guide and here is the Python library GPIO reference.

In this case, you would use the expansion GPIO pins on the back of the MATRIX Creator as shown here.

It should be a fairly simple swap but let me know if you need any help!

Best,
Samreen

1 Like