HI,
I have just started to write c code. please suggest me i am going to wrong way
algorithm
If sensor is High -both motor move forward
If sensor is Low- stop both motor
PORT A A0 A1 A2 A3 A4 A5 A6 A7 output of sensor is connected to A4 pin
0 0 0 0 1 0 0 0
PORT B B0 B1 B2 B3 B4 B5 B6 B7 motor1 and motor2 connected pin 2345
0 0 1 1 1 1 0 0
[#include<AVR/IO.h>
main()
while(1)
{
DDRA=OXOO; //port A as input
DDRB=OXFF; //port B as output
PORTA=0b00001000; // set as high pin
PORTA=0b00000000; //set as low pin
{
If (port A=00001000); //If sensor is high
{
(port B=0b00111100); // both motor move forward
}
If (port A=00000000); //If sensor is Low
{
(port B=00000000); //stop both motor
}
}
}
]
I have just started to write c code. please suggest me i am going to wrong way
algorithm
If sensor is High -both motor move forward
If sensor is Low- stop both motor
PORT A A0 A1 A2 A3 A4 A5 A6 A7 output of sensor is connected to A4 pin
0 0 0 0 1 0 0 0
PORT B B0 B1 B2 B3 B4 B5 B6 B7 motor1 and motor2 connected pin 2345
0 0 1 1 1 1 0 0
[#include<AVR/IO.h>
main()
while(1)
{
DDRA=OXOO; //port A as input
DDRB=OXFF; //port B as output
PORTA=0b00001000; // set as high pin
PORTA=0b00000000; //set as low pin
{
If (port A=00001000); //If sensor is high
{
(port B=0b00111100); // both motor move forward
}
If (port A=00000000); //If sensor is Low
{
(port B=00000000); //stop both motor
}
}
}
]
Last edited by a moderator: