1

An example of the title question code is shown below. Is there a way to run this code from a Python IDE (like Spyder)? I say this after trying it and having no success. I have installed the Adafruit library and straight out of the box, there's no sign of life. I guess I need to assign COM port somewhere and assign pins somehow.

Arduino IDE Script:

import time
import Adafruit_MCP4725
dac = Adafruit_MCP4725.MCP4725(address=0x62)

print('Press Ctrl-C to quit...')
while True:
    print('Setting voltage to 0!')
    dac.set_voltage(0)
    time.sleep(2.0)
    print('Setting voltage to 1/2 Vdd!')
    dac.set_voltage(2048)  # 2048 = half of 4096
    time.sleep(2.0)
    print('Setting voltage to Vdd!')
    dac.set_voltage(4096, True)
    time.sleep(2.0)
E_net4
  • 27,810
  • 13
  • 101
  • 139
jimbob
  • 11
  • 3
  • 1
    Are you intending the Python IDE to drive the Arduino or is this just a simulation? – Sean Duggan May 03 '21 at 17:22
  • Hi, I'm attempting to replace the use of Arduino IDE with Sypder, then eventually (once I learn pyqt5) with a self-made gui. I have gotten to grips controlling digital ports on the arduino using pyfirmata, and i was hoping to control an DAC device (MCP4725) over i2c.I was hoping it be as straightforward as pyfirmata, but so far really struggling to make things work. NB: everything works via the Arduino script and Arduino IDE. – jimbob May 03 '21 at 17:46
  • It might help you in some regard: [Another question of stackoverflow](https://stackoverflow.com/questions/8114916/is-there-a-way-to-compile-python-code-onto-an-arduino-uno) – FahimFBA May 03 '21 at 18:10
  • Hi Fahim, I had a read and it does look somewhat relevant. A python-to-arduino compiler might be the terminology that I have been failing to consider. I am thinking that another approach might to bit-bash my way out using the digital library of pyfirmata in order to create my own i2c driver. – jimbob May 03 '21 at 18:32

0 Answers0