GY-63_MS5611/libraries/DAC8554/examples/DAC8554_powerdown/DAC8554_powerdown.ino

66 lines
1.3 KiB
Arduino
Raw Normal View History

2017-12-19 05:44:03 -05:00
//
// FILE: DAC8554_powerdown.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo DAC8554 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/Arduino/DAC8554
//
2021-01-29 06:31:58 -05:00
2017-12-19 05:44:03 -05:00
#include "DAC8554.h"
2021-01-29 06:31:58 -05:00
2017-12-19 05:44:03 -05:00
// HW SPI
2021-01-29 06:31:58 -05:00
DAC8554 mydac(10);
2017-12-19 05:44:03 -05:00
uint8_t chanA = 0;
uint8_t chanB = 1;
uint8_t chanC = 2;
uint8_t chanD = 3;
2021-12-15 08:57:49 -05:00
2017-12-19 05:44:03 -05:00
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.println(DAC8554_LIB_VERSION);
2021-01-29 06:31:58 -05:00
mydac.begin();
2017-12-19 05:44:03 -05:00
2021-01-29 06:31:58 -05:00
mydac.setValue(chanA, 0);
mydac.setPowerDown(chanB, DAC8554_POWERDOWN_HIGH_IMP);
mydac.setPowerDown(chanC, DAC8554_POWERDOWN_100K);
mydac.setPowerDown(chanD, DAC8554_POWERDOWN_1K);
2017-12-19 05:44:03 -05:00
}
2021-12-15 08:57:49 -05:00
2017-12-19 05:44:03 -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);
2017-12-19 05:44:03 -05:00
}
Serial.println("Stop DAC for 5 seconds");
2021-01-29 06:31:58 -05:00
mydac.setPowerDown(chanA, DAC8554_POWERDOWN_HIGH_IMP);
2017-12-19 05:44:03 -05:00
uint32_t start = millis();
while (millis() - start < 5000);
2021-01-29 06:31:58 -05:00
mydac.setPowerDown(chanA, DAC8554_POWERDOWN_NORMAL);
2017-12-19 05:44:03 -05:00
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);
2017-12-19 05:44:03 -05:00
}
Serial.println("Stop DAC for 5 seconds");
2021-01-29 06:31:58 -05:00
mydac.setPowerDown(chanA, DAC8554_POWERDOWN_HIGH_IMP);
2017-12-19 05:44:03 -05:00
start = millis();
while (millis() - start < 5000);
2021-01-29 06:31:58 -05:00
mydac.setPowerDown(chanA, DAC8554_POWERDOWN_NORMAL);
2017-12-19 05:44:03 -05:00
}
2021-12-15 08:57:49 -05:00
// -- END OF FILE --