My goal is to do this...
Have pins 27 and 28 as inputs, connected to photoresistors, and have pins 2,3,4 as outputs. When Pin 27 goes high and pin 28 is low, I would like Pin 2 to go high, pin 3 to go low, and pin 4 to go high. When Pin 28 goes high and pin 27 is low, I would like pin 2 to go low, pin 3 to go high, and pin 4 to go high. When Pin 27 and 28 are both high i would like pin 2 to go low, pin 3 to go low and pin 4 to go high. When pin 27 and 28 are both low i want pin 2 to go low, pin 3 to go low and pin 4 to go low. This is the code i have so far...
#include <avr/io.h>
void beep (unsigned char cycles)
{
DDRD |=1<<PD0;
DDRD |=1<<PD1;
DDRD |=1<<PD2;
return;
}
int main(void)
{
int sensor_left=0;
int sensor_right=0;
while(1)
{
sensor_left=a2dConert8bit(5);
sensor_right=a2dConvert8bit(4);
if(sensor_left > sensor_right)
{
PORTD |=1<<PD0;
PORTD &=!(1<<PD1);
PORTD |=1<<PD2;
}
else if(sensor_right > sensor_left)
{
PORTD &=!(1<<PD0);
PORTD |=1<<PD1;
PORTD |=1<<PD2;
}
else
{
PORTD &=!(1<<PD0);
PORTD &=!(1<<PD1);
PORTD |=1<<PD2;
}
}
return 0;
}