! 12ビットDAC http://akizukidenshi.com/catalog/g/gK-08677/ https://amzn.to/3bA870k ! ArduinoIDE https://github.com/adafruit/Adafruit_MCP4725 !micoropython git https://github.com/wayoda/micropython-mcp4725 ! PinOUT ,MCP4725bord,STM32,esp32 ,out, ,gnd, ,scl,PB6(SCL1),gpio-22 ,sda,PB7(SDA1),gpio-21 ,vcc,3v3 ,gnd,GND ! Sample / stm32f103 arudiono ide /**************************************************************************/ #include #include Adafruit_MCP4725 dac; int sensorPin1 = 0; // Select the input pin for the potentiometer int sensorPin2 = 2; // Select the input pin for the potentiometer void setup(void) { Serial.begin(9600); Serial.println("Hello!"); pinMode(sensorPin1, INPUT_ANALOG); pinMode(sensorPin2, INPUT_ANALOG); // For Adafruit MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC) // For MCP4725A0 the address is 0x60 or 0x61 // For MCP4725A2 the address is 0x64 or 0x65 // dac.begin(0x62); dac.begin(0x60); Serial.println("Generating a triangle wave"); } //************************************************* float lsb = 3.3/4095 ; void loop(void) { uint32_t counter; int tm1 = 0; int tm2 = 0; // tmp2 = 0; // Run through the full 12-bit scale for a triangle wave for (counter = 1; counter < 100; counter++) { // TEMPsenser tm2 = analogRead(sensorPin2); // dac.setVoltage(tm2, false); delay(250); tm1 = analogRead(sensorPin1); Serial.print(tm2); Serial.print(","); Serial.print(tm2-tm1); Serial.print(","); Serial.println( (((tm2*lsb)-0.50)*10.0) ,3); delay(250); } } ---- ! micropython ESP32 # ここにコードを書いてね :-) from machine import I2C,Pin import time import mcp4725 #create a I2C bus i2c=I2C(freq=400000,scl=Pin(22), sda=Pin(21)) #create the MCP4725 driver ## dac=mcp4725.MCP4725(i2c,mcp4725.BUS_ADDRESS[0]) dac=mcp4725.MCP4725(i2c,96) ###Update the output on the MCP4725 The simple way to update the output on the DAC is to write a new value to the device for i in range(1,1000,100): dac.write(i) time.sleep_ms(3500) dac.write(100) !others tips-mcp4922