sterretje:
If you give us an example of one of those functions, we might be able to advise how to break it into smaller chunks.
Thanks for the tips!
I - indeed - am used to a bit of VBA-programming, but the reason i wanted to use the button to interrupt (and not just poll) is to be able to put the arduino to sleep when i don't use it. It could then wake up with the button or on a set time (every hour to check the times).
The code below doesn't work all the way, i think because i had several parts working separately and tried to put them together. 
The display showed the temperature (worked) and the light went smooth from blue over orange to white. So those parts worked. The button worked, but not in the ISR, as it is here.
// LIBRARIES
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_SSD1306.h>
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
#define OLED_RESET 2
Adafruit_SSD1306 display(OLED_RESET);
// I/0 PINS
const int LEDstrip_W = 6; //PWM white LEDS
const int LEDstrip_R = 9; //PWM red LEDS
const int LEDstrip_G = 10; //PWM green LEDS
const int LEDstrip_B = 11; //PWM blue LEDS
const int button = 2; //button interrupt pin
const int SQW = 3; //RTC interrupt pin
//TIMERS
unsigned long sun_time = 300000; //--- TEMP 5 MINUTES --- #seconds from dark to light and vv (will become 1/2 hour? 10minutes?)
// unsigned long moon_time = 60; //--- TEMP 1 MINUTE --- #seconds from dark to blue (will become 5 or 10 minutes?)
volatile unsigned long timer_button = 0; //to return the millis from the button interrupt
unsigned int cnt = 0; // counter for the sun_time loop
unsigned int step_time = 0; // each brightness step-time.
unsigned long prev_millis = 0;
// COLORS
int W = 0;
int R = 0;
int G = 0;
int B = 0;
float Q = 0;
const int PWM_steps = 100; //#steps from 0 >> 255
int PWM_tot_steps = 0; //
int brightness = 0;
//ALARMS
byte time_sunrise = 13;
byte time_sunset = 22;
byte time_moonrise = 6;
byte time_moonset = 00;
// BUTTONS
volatile boolean buttonPush;
// STATUS
bool sun_rising = 0;
void ISR_button() {
buttonPush = true;
timer_button = millis();
}
void setup() {
Serial.begin(9600);
sensors.begin(); //for temperature
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
display.clearDisplay();
//SET PINS
pinMode(LEDstrip_W, OUTPUT);
pinMode(LEDstrip_R, OUTPUT);
pinMode(LEDstrip_G, OUTPUT);
pinMode(LEDstrip_B, OUTPUT);
pinMode(buttonPush, INPUT_PULLUP);
//INTERRUPTS
attachInterrupt(digitalPinToInterrupt(button), ISR_button, FALLING);
//(RE)SET LEDS
analogWrite(LEDstrip_R, 0);
analogWrite(LEDstrip_G, 0);
analogWrite(LEDstrip_B, 0);
analogWrite(LEDstrip_W, 0);
//
cnt = 0;
Q = (PWM_steps * (log10(2))) / (log10(255)); //because LEDS I/O is exponential
PWM_tot_steps = PWM_steps * 3; //the brightness curve i use takes 3x the steps it takes to go from 0 to 255 (because not all need to go to 255)
step_time = sun_time / (3 * PWM_steps); //each steps takes the total time (in ms) x 1000 (s) / 7 (phases) / #steps
}
void loop() {
//wakeup, for when i use it with sleep mode
if((time_sunrise == rtc.hour) || (sun_rising == 1){
sun_rising = 1;
SunRise();
}
if (buttonPush == 1) tempSensor();
}
void SunRise() {
if((cnt >= (PWM_tot_steps * 0 / 6)) && (cnt < (PWM_tot_steps * 1 / 6))) {
B++ ;
brightness = pow (2, (B / Q));
analogWrite(LEDstrip_B, brightness);
}
if((cnt >= (PWM_tot_steps * 1 / 6)) && (cnt < (PWM_tot_steps * 2 / 6))) {
R++;
brightness = pow (2, (R / Q));
analogWrite(LEDstrip_R, brightness);
}
if((cnt >= (PWM_tot_steps * 2 / 6)) && (cnt < (PWM_tot_steps * 3 / 6))) {
R++;
brightness = pow (2, (R / Q));
analogWrite(LEDstrip_R, brightness);
B--;
brightness = pow (2, (B / Q));
analogWrite(LEDstrip_B, brightness);
G++;
brightness = pow (2, (G / Q));
analogWrite(LEDstrip_G, brightness);
}
if((cnt >= (PWM_tot_steps * 3 / 6)) && (cnt < (PWM_tot_steps * 4 / 6))) {
W++;
brightness = pow (2, (W / Q));
analogWrite(LEDstrip_W, brightness);
}
if((cnt >= (PWM_tot_steps * 4 / 6)) && (cnt < (PWM_tot_steps * 5 / 6))) {
W++;
brightness = pow (2, (W / Q));
analogWrite(LEDstrip_W, brightness);
G--;
brightness = pow (2, (G / Q));
analogWrite(LEDstrip_G, brightness);
R--;
brightness = pow (2, (R / Q));
analogWrite(LEDstrip_R, brightness);
}
if((cnt >= (PWM_tot_steps * 5 / 6)) && (cnt <= (PWM_tot_steps * 6 / 6))) {
R--;
brightness = pow (2, (R / Q));
analogWrite(LEDstrip_R, brightness);
}
// run once per step_time:
while (millis() - prev_millis < step_time) delay(1);
prev_millis = millis();
cnt++;
if((cnt == (PWM_tot_steps)) && (R == 0) && (G == 0) && (B == 0)){
analogWrite(LEDstrip_R, 0);
analogWrite(LEDstrip_G, 0);
analogWrite(LEDstrip_B, 0);
analogWrite(LEDstrip_W, 255);
cnt = 0;
sun_rising = 0;
}
}
void tempSensor() {
if((buttonPush == 1) && (millis() - timer_button < 5000 )){
sensors.requestTemperatures(); // Send the command to get temperature readings
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Water temperature");
display.setTextSize(3);
display.setTextColor(WHITE);
display.print(sensors.getTempCByIndex(0));
display.println("C");
display.display();
delay(500);
display.clearDisplay();
}
else{
buttonPush = 0;
}
}