GY-63_MS5611/libraries/DAC8552/examples/DAC8552_powerdown/DAC8552_powerdown.ino

59 lines
1.2 KiB
Arduino
Raw Normal View History

//
// FILE: DAC8552_powerdown.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo DAC8552 library Arduino
2021-01-29 06:31:58 -05:00
// VERSION: 0.2.0
2020-11-27 05:10:47 -05:00
// URL: https://github.com/RobTillaart/DAC8552
//
2021-01-29 06:31:58 -05:00
#include "DAC8552.h"
2021-01-29 06:31:58 -05:00
// HW SPI
2021-01-29 06:31:58 -05:00
DAC8552 mydac(10);
uint8_t chanA = 0;
uint8_t chanB = 1;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.println(DAC8552_LIB_VERSION);
2021-01-29 06:31:58 -05:00
mydac.begin();
2021-01-29 06:31:58 -05:00
mydac.setValue(chanA, 0);
mydac.setPowerDown(chanB, DAC8552_POWERDOWN_HIGH_IMP);
}
2021-01-29 06:31:58 -05:00
void loop()
{
Serial.println("Start sawtooth");
for (uint16_t i = 0; i < 32000; i+= 100)
{
2021-01-29 06:31:58 -05:00
mydac.setValue(chanA, i);
}
Serial.println("Stop both DAC's for 5 seconds");
2021-01-29 06:31:58 -05:00
mydac.setPowerDown(chanA, DAC8552_POWERDOWN_HIGH_IMP);
uint32_t start = millis();
while (millis() - start < 5000);
2021-01-29 06:31:58 -05:00
mydac.setPowerDown(chanA, DAC8552_POWERDOWN_NORMAL);
Serial.println("Continue sawtooth");
for (uint16_t i = 32000; i < 64000; i+= 100)
{
2021-01-29 06:31:58 -05:00
mydac.setValue(chanA, i);
}
Serial.println("Stop both DAC's for 5 seconds");
2021-01-29 06:31:58 -05:00
mydac.setPowerDown(chanA, DAC8552_POWERDOWN_HIGH_IMP);
start = millis();
while (millis() - start < 5000);
2021-01-29 06:31:58 -05:00
mydac.setPowerDown(chanA, DAC8552_POWERDOWN_NORMAL);
}
2020-11-27 05:10:47 -05:00
// -- END OF FILE --