The following code:
struct l{
uint8_t pin;
uint8_t sensePin;
float brightnessTarget;
uint8_t PWMvalue;
uint8_t inc;
};
typedef struct l led;
led* redLed;
led* whiteLed;
unsigned long secondsOfDay = 79140;
unsigned long minutesOfDay = 0;
unsigned int hoursOfDay = 0;
uint8_t interrupted=0;
uint8_t runPID;
int pin13=0;
void setup() {
cli();
TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1 = 0;//initialize counter value to 0
// set compare match register for 1hz increments
OCR1A = OCR1A_val;// = (16*10^6) / (1*1024) - 1 (must be <65536)
// turn on CTC mode
TCCR1B |= (1 << WGM12);
// Set CS10 and CS12 bits for 1024 prescaler
TCCR1B |= (1 << CS12) | (1 << CS10);
// enable timer compare interrupt
TIMSK1 |= (1 << OCIE1A);
pinMode(13,OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
sei();
}
void loop() {
if (runPID){
PIControl(redLed);
PIControl(whiteLed);
pin13 = (~pin13 & 1);
digitalWrite(13, pin13);
runPID=0;
}
}
SIGNAL(TIMER1_COMPA_vect){ //1 second timer fire
runPID = 1;
}
Toggles a pin. However, if I add:
redLed->pin = 3;
whiteLed->pin = 4;
redLed->sensePin = 0;
whiteLed->sensePin = 1;
In the setup anywhere (before cli(), after sei(), or within the block), the interrupt no longer toggles.
I'm absolutely baffled, and I have no idea what's going on.
Edit: everything but whiteLed->sensePin is fine. That line is what is causing the issue (and I still don't understand)