Recently, for a project I was doing, I wanted to use theAnalog Discovery 2to help intelligently interpret live audio and send the data to LED strips controlled by an Arduino. However, in order to do this, I would needWaveFormsto have some way to talk to the Arduino. After exploring some options on my own, I turned to theDigilent Forumand posted the following question.
Before I knew it I had a solution proposed to me by attila, a Technical Forum Moderator and WaveForms software developer. He suggested using the Python libraries in WaveForms SDK by doing the following:
You could use the WaveForms SDK. Starting with the AnalogIn_Record_int16.py or AnalogIn_Record.py example script and modifying it to send the data chunks from the record loop to the desired protocol (like COM), or using the device DIO (see Digital_Spi.py, Digital_Uart.py, Digital_I2c.py)
The examples are located in the following path: C:/Program Files (x86)/Digilent/WaveFormsSDK/samples/py/
He also suggested that I could also send acquisition data over SPI with a custom script in the script editor like the one shown below:
Scope1.run()while(Scope1.wait()){varrg16=[]varr=Scope1.Channel1.Range.valuevaro=Scope1.Channel1.Offset.value// convert float to 16bit integerScope1.Channel1.alldata.forEach(function(v){rg16.push(max(-32768,min(32767,v*32768/r+o)))})Protocol.SPI.Start()if(!Protocol.SPI.Write(16,rg16))breakProtocol.SPI.Stop()}
设计我在工作,这个沟通is essential, as I am basically using the Analog Discovery 2 as an advanced sound sensor. Since my current setup involves manipulating the data from WaveForms in the Arduino IDE, I am going to experiment with attila’s suggested option of using the AnalogIn_Record example scripts to send to the COM port that the Arduino is on.
Stay tuned for updates on this project as well as how to use the Analog Discovery 2 with Arduino!

