Skip to main content
edited body
Source Link

I have merged my program with your program and I have added the -#include "Arduino.h"-#include "Arduino.h". The millis()millis() function is colored now and works. My code still won't stop at 60 secondes, did I do something wrong?

I have merged my program with your program and I have added the -#include "Arduino.h"-. The millis() function is colored now and works. My code still won't stop at 60 secondes, did I do something wrong?

I have merged my program with your program and I have added the #include "Arduino.h". The millis() function is colored now and works. My code still won't stop at 60 secondes, did I do something wrong?

edited tags
Link
Post Reopened by VE7JRO
added 2496 characters in body
Source Link

I have merged my program with your program and I have added the -#include "Arduino.h"-. The millis() function is colored now and works. My code still won't stop at 60 secondes, did I do something wrong?

#include "hva-xmega.h"
#include "Arduino.h"


unsigned long EndTime;

void setup()
{
    pin_mode(A13,INPUT);
    pin_mode(A12,INPUT);
    pin_mode(A11,INPUT);
    pin_mode(A10,INPUT);
    pin_mode(A15,INPUT);
    pin_mode(D0,OUTPUT);
    pin_mode(D1,OUTPUT);
    pin_mode(D2,OUTPUT);
    pin_mode(D3,OUTPUT);


    EndTime = millis() + (60*1000L);
}


void loop() {
    if( millis() < EndTime ){

while (1)
{
    int potmeter1 = read_analog_pin(A13);
    if (potmeter1 >= 1000 && potmeter1 < 1100){
        gen_pwm(D0, 1000, 100);
        
        int potmeter2 = read_analog_pin(A12);
        if (potmeter2 >= 2000 && potmeter2 < 2050){
            gen_pwm(D1, 1000, 100);
            
            int potmeter3 = read_analog_pin(A11);
            if (potmeter3 >= 500 && potmeter3 < 525){
                gen_pwm(D2, 1000, 100);
                
                int potmeter4 = read_analog_pin(A10);
                if (potmeter4 >= 3500 && potmeter4 < 3510){
                    gen_pwm(D3, 1000, 100);

                    {
                        int lichtsensor = read_analog_pin(A15);
                        if (lichtsensor >= 2000 && lichtsensor < 3500 && potmeter1 >= 1000 && potmeter1 < 1100 && potmeter2 >= 2000 && potmeter2 < 2050 && potmeter3 >= 500 && potmeter3 < 525 && potmeter4 >= 3500 && potmeter4 < 3510){
                            gen_pwm(D0, 1000, 100);
                            gen_pwm(D1, 1000, 100);
                            gen_pwm(D2, 1000, 100);
                            gen_pwm(D3, 1000, 100);
                            _delay_ms(250);
                            gen_pwm(D0, 1000, 0);
                            gen_pwm(D1, 1000, 0);
                            gen_pwm(D2, 1000, 0);
                            gen_pwm(D3, 1000, 0);
                            _delay_ms(250);
                            
                        }
                    }
                    }else{
                    gen_pwm(D3, 1000, 0);
                }
                }else{
                gen_pwm(D3, 1000, 0);
                gen_pwm(D2, 1000, 0);
            }
            }else{
            gen_pwm(D3, 1000, 0);
            gen_pwm(D2, 1000, 0);
            gen_pwm(D1, 1000, 0);
        }
        }else{
        gen_pwm(D3, 1000, 0);
        gen_pwm(D2, 1000, 0);
        gen_pwm(D1, 1000, 0);
        gen_pwm(D0, 1000, 0);
            }
        }
    }   
}
 else {
     // Time is up! Hang here
     for(;;)
     ;      // infinite loop here stops further processing
    }
 }

I have merged my program with your program and I have added the -#include "Arduino.h"-. The millis() function is colored now and works. My code still won't stop at 60 secondes, did I do something wrong?

#include "hva-xmega.h"
#include "Arduino.h"


unsigned long EndTime;

void setup()
{
    pin_mode(A13,INPUT);
    pin_mode(A12,INPUT);
    pin_mode(A11,INPUT);
    pin_mode(A10,INPUT);
    pin_mode(A15,INPUT);
    pin_mode(D0,OUTPUT);
    pin_mode(D1,OUTPUT);
    pin_mode(D2,OUTPUT);
    pin_mode(D3,OUTPUT);


    EndTime = millis() + (60*1000L);
}


void loop() {
    if( millis() < EndTime ){

while (1)
{
    int potmeter1 = read_analog_pin(A13);
    if (potmeter1 >= 1000 && potmeter1 < 1100){
        gen_pwm(D0, 1000, 100);
        
        int potmeter2 = read_analog_pin(A12);
        if (potmeter2 >= 2000 && potmeter2 < 2050){
            gen_pwm(D1, 1000, 100);
            
            int potmeter3 = read_analog_pin(A11);
            if (potmeter3 >= 500 && potmeter3 < 525){
                gen_pwm(D2, 1000, 100);
                
                int potmeter4 = read_analog_pin(A10);
                if (potmeter4 >= 3500 && potmeter4 < 3510){
                    gen_pwm(D3, 1000, 100);

                    {
                        int lichtsensor = read_analog_pin(A15);
                        if (lichtsensor >= 2000 && lichtsensor < 3500 && potmeter1 >= 1000 && potmeter1 < 1100 && potmeter2 >= 2000 && potmeter2 < 2050 && potmeter3 >= 500 && potmeter3 < 525 && potmeter4 >= 3500 && potmeter4 < 3510){
                            gen_pwm(D0, 1000, 100);
                            gen_pwm(D1, 1000, 100);
                            gen_pwm(D2, 1000, 100);
                            gen_pwm(D3, 1000, 100);
                            _delay_ms(250);
                            gen_pwm(D0, 1000, 0);
                            gen_pwm(D1, 1000, 0);
                            gen_pwm(D2, 1000, 0);
                            gen_pwm(D3, 1000, 0);
                            _delay_ms(250);
                            
                        }
                    }
                    }else{
                    gen_pwm(D3, 1000, 0);
                }
                }else{
                gen_pwm(D3, 1000, 0);
                gen_pwm(D2, 1000, 0);
            }
            }else{
            gen_pwm(D3, 1000, 0);
            gen_pwm(D2, 1000, 0);
            gen_pwm(D1, 1000, 0);
        }
        }else{
        gen_pwm(D3, 1000, 0);
        gen_pwm(D2, 1000, 0);
        gen_pwm(D1, 1000, 0);
        gen_pwm(D0, 1000, 0);
            }
        }
    }   
}
 else {
     // Time is up! Hang here
     for(;;)
     ;      // infinite loop here stops further processing
    }
 }
Post Closed as "Not suitable for this site" by Juraj, VE7JRO
Source Link
Loading