Controlling a PWM over I2C

Aus DL8RDS Wiki
Wechseln zu: Navigation, Suche

Pulse Width Modulation is a way to control the production of voltages. The hardware that is being used here is a BV4237:

The below given code sample is based on the code presented by the BB user wilkosoft:

#include <Wire.h>

#define dac 0x31

void sw16set(byte val) {
  Wire.beginTransmission(dac);  // join I2C, talk to BV4206 by id
  Wire.send(0x16);   //tell it what pin you want
  Wire.send(val);  //the state of the pin, from 0-8 (PWM controls the levels)
  Wire.endTransmission();      // leave I2C bus
  delay(100) ;

void setup()

void loop()
  for (byte i=0; i<9; i++) {