100 static int32_t previous_adc_code;
102 int32_t delta_adc_code;
114 delta_adc_code = adc_code - previous_adc_code;
116 uint8_t pin2=0, pin3=0, pin4=0;
117 if (delta_adc_code > 30) pin2 = 1;
118 if ((delta_adc_code <= 30) && (delta_adc_code >=-30)) pin3=1;
119 if (delta_adc_code < -30) pin4=1;
121 digitalWrite(2,pin2);
122 digitalWrite(3,pin3);
123 digitalWrite(4,pin4);
126 Serial.print(
"RED: ");
127 Serial.println(pin4);
128 Serial.print(
"GREEN: ");
129 Serial.println(pin3);
130 Serial.print(
"BLUE: ");
131 Serial.println(pin2);
LTC2422: 1-/2-Channel 20-Bit uPower No Latency Delta-Sigma ADC in MSOP-10.
uint16_t LTC2607_voltage_to_code(float dac_voltage, float LTC2607_lsb, int32_t LTC2607_offset)
Calculates an LTC2607 DAC code for the desired output voltage.
const uint16_t LTC2422_timeout
The timeout for the LTC2422.
#define output_high(pin)
Set "pin" high.
const float LTC2607_TYPICAL_OFFSET
The LTC2607 typical offset voltage.
Header File for Linduino Libraries and Demo Code.
const float LTC2607_TYPICAL_lsb
The LTC2607 typical least significant bit value with 5V full-scale.
void LTC2422_adc_read(uint8_t cs, uint8_t *adc_channel, int32_t *code)
Read ADC code from the LTC2422.
#define LTC2607_WRITE_UPDATE_COMMAND
Command to write and update (and power up) the LTC2607.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
#define LTC2607_POWER_DOWN_COMMAND
Command to power down the LTC2607.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC2607_DAC_B
Command (and DAC code) will modify DAC B.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
#define LTC2607_I2C_GLOBAL_ADDRESS
LTC2607 Global I2C Address.
#define LTC2422_CS
Define the SPI CS pin.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
LTC2607: 16-Bit, Dual Rail-to-Rail DACs with I2C Interface.
int8_t LTC2607_write(uint8_t i2c_address, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Writes command, DAC address, and DAC code to the LTC2607.
#define LTC2607_DAC_A
Command (and DAC code) will modify DAC A.
uint8_t LTC2422_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
static void setup()
Initialize Linduino once on power-up or reset.