Moderators: adafruit_support_bill, adafruit
for (counter=0 ; counter < 4095 ; counter += 100) {
dac.setVoltage( counter, false );
delay( 10 );
}
for (counter=4095 ; counter >0 ; counter -= 100) {
dac.setVoltage( counter, false );
delay( 10 );
}
for (counter=0 ; counter < 80 ; counter++) {
dac.setVoltage( (100 * abs( 40 - counter )), false );
delay( 5 );
}
/**************************************************************************/
/*!
@file trianglewave.pde
@author Adafruit Industries
@license BSD (see license.txt)
This example will generate a triangle wave with the MCP4725 DAC.
This is an example sketch for the Adafruit MCP4725 breakout board
----> https://www.adafruit.com/products/???
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
*/
/**************************************************************************/
#include <Wire.h>
#include <Adafruit_MCP4725.h>
Adafruit_MCP4725 dac;
void setup(void) {
Serial.begin(9600);
Serial.println("Hello!");
// 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);
Serial.println("Generating a triangle wave");
}
void loop(void) {
uint32_t counter;
// Run through the full 12-bit scale for a triangle wave
for (counter = 0; counter < 4000; counter+=100)
{
dac.setVoltage(counter, false);
//dac.setVoltage(0, false);
}
for (counter = 4000; counter > 0; counter-=100)
{
dac.setVoltage(counter, false);
//dac.setVoltage(4095, false);
}
// for (counter=0 ; counter < 80 ; counter++) {
// dac.setVoltage( (100 * abs( 40 - counter )), false );
// delay( 1 );
//}
}
Return to Other Adafruit products
Users browsing this forum: No registered users and 9 guests