ArdyNT
Full Member level 2
- Joined
- Nov 6, 2012
- Messages
- 126
- Helped
- 7
- Reputation
- 14
- Reaction score
- 7
- Trophy points
- 1,298
- Activity points
- 2,304
Like this?
Code:
void change_intensity()
{
static unsigned int motor_flagA;
static unsigned int inten_flagA;
// If light intensity below the setpoint, open blinds, and shorten the firing delay
if((ldr1 <= 500) && (motor_flagA < 1))
{
turn_A(ARIGHT,23);
motor_flagA++;
}
#asm("cli")
if((PORTB.0 == 1) && (ldr1 <= 500) && (motor_flagA == 1))
{
if(x > 1)
{
x = x - 1;
}
}
// If light intensity greater than the setpoint, increase the firing delay, and close blinds
if((PORTB.0 == 1) && (ldr1 >= 550))
{
if(x < 280)
{
x = x + 1;
inten_flagA++;
}
}
#asm("sei")
if((ldr1 >= 550) && (inten_flagA == 1) && (motor_flagA == 1))
{
turn_A(ALEFT,23);
motor_flagA = 0;
inten_flagA = 0;
}
[COLOR="#FF0000"]// But here will be the second motor, can I disable it again[/COLOR]
// If light intensity below the setpoint, open blinds, and shorten the firing delay
if((PORTB.1 == 1) && (ldr2 <= 500))
{
if(y > 1)
{
y = y - 1;
}
}
// If light intensity greater than the setpoint, increase the firing delay, and close blinds
if((PORTB.1 == 1) && (ldr2 >= 550))
{
if(y < 280)
{
y = y + 1;
}
}
// If light intensity below the setpoint, open blinds, and shorten the firing delay
if((PORTB.2 == 1) && (ldr3 <= 500))
{
if(z > 1)
{
z = z - 1;
}
}
// If light intensity greater than the setpoint, increase the firing delay, and close blinds
if((PORTB.2 == 1) && (ldr3 >= 550))
{
if(z < 280)
{
z = z + 1;
}
}
}