#include #define LIGHTSENSOR_PIN A1 #define CAPSENSE_PIN A2 // works for both A2 and D2 due to Arduino libraries #define DRIVE_PIN D10 #define GND_PIN A0 #define VDD_PIN A3 // will add a jumper for this float getDCVD(uint16_t pow2samps) { uint16_t samps = 0x01 << pow2samps; int32_t temp; int32_t capsenseVal = 0; for(uint16_t n = 0; n10ms, set PWM to small number // If again, set PWM to medium number // If again, set PWM to high number // If again, set PWM to zero. //// // If phototransistor reads current >= value for >2s, set PWM to small number (dim) // If phototransistor reads current < value for >2s, set PWM to high number (bright) // if (analogRead(LIGHTSENSOR_PIN < 3500)) // (3500/4095)*3.3 = 2.8V; max value will be 4095 since RP2040 ADC is 12-bit (2^12 - 1) // {analogWrite(DRIVE_PIN, pow(number, 0.33))} // taking the 0.33 root of measured brightness is an approximation for perceived brightness