Tinkercad和LTspice仿真Arduino音频
Last updated
Was this helpful?
Last updated
Was this helpful?
Tinkercad LTspice | Arduino | 音频 | 传感器 | 模数转换(ADC) | 正弦波 | 音频放大器 | 运算放大器 | 音频滤波器 | 高通滤波器 (HPF) | 低通洉波器 (LPF) | 数字滤波器
#include <SPI.h>
const byte lowPassLED = 2;
const byte highPassLED = 3;
const byte selectButtonPin = 4;
const byte potInputPin = A0;
const byte lowPassPot = 9;
const byte highPassPot = 10;
int buttonState = 0;
int lastButtonState = 0;
bool pushedButton = false;
int currentPotValue = 0;
to detect change)
int potInputValue = 0;
const byte potWriteCommand = 0x00;
void setup()
{
pinMode(selectButtonPin, INPUT);
pinMode(potInputPin, INPUT);
pinMode(lowPassLED, OUTPUT);
pinMode(highPassLED, OUTPUT);
pinMode (lowPassPot, OUTPUT);
pinMode (highPassPot, OUTPUT);
digitalWrite(lowPassPot, HIGH);
digitalWrite(highPassPot, HIGH);
SPI.begin();
}
void updateDigitalPot(){
if(lastButtonState == 1){
digitalWrite(lowPassPot, LOW);
commands
SPI.transfer(potWriteCommand);
to the SDI/SDO pin
SPI.transfer(currentPotValue/10);
to 0-127)
digitalWrite(lowPassPot, HIGH);
}