Thanks ppl, i got it working but a lot of the times when i run the code its running slowly.
Im sending simple midi signals to the pc.
Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*- Simple example of reading the MCP3008 analog
# input channels and printing them all out. Author: Tony DiCola License:
# Public Domain
import time
import os
import Adafruit_GPIO.SPI as SPI
import Adafruit_MCP3008
SPI_PORT = 0
SPI_DEVICE = 0
mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
os.chdir("/home/pi/SendMIDI/")
while True:
pot0 = str(mcp.read_adc(0) * 16)
time.sleep(0.0001)
#if pot0c != pot0:
os.system("./sendmidi dev f_midi pb " + pot0)
So i want to read the MCP3008 A/D Converter and pass it trough the file 'sendmidi'.
I want to be able to control a knob in a software called ableton.
Here's the slow running code:
https://i.gyazo.com/e1a9d70cf433668794a ... 4c7973.mp4
here's the fast running code:
https://i.gyazo.com/2599f4e6ca9b146b55d ... 937a64.mp4
I think it has something to do with the infinite loop not properly executing. Can you guys help to make it run smooth every time?