# Help on programming...

Discussion created by lpcware on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by raghavendrabsrg on Tue Nov 01 05:44:54 MST 2011
Hi, Im a beginner in LPC and desperately need your help guys.

I've to make a simple robot for a competition (with NO prize money), deadline is 3days.

Now I've written a simple algorithm of how the bot works, And its running pretty with an AVR 128(atmel).

But im not able to startup good with LPCxpresso 1114/302...

So i actually needed some real code that works.. if you can help, i'd be greatful to you...

Algorithm -
Objective: The robot must find its enemy bot, and then push the enemy bot out of the arena which is a circle of black line.
To find black line and to be inside the circle i've used line sensors.
To find the enemy bot i've used a obstacle sensor.

S1 is a left side line sensor.
s2 is a right side line sensor.
A1 is a obstacle sensor at front of the bot.

//program begins

#includes ??

main()   // main program begins
{

while(1)   // let the main program run forever in the MCU.
{

If((s1||s2) == 0)  // bot is inside the circle, so search the target.
{
Searchmode();
}

If(s1 == 1)  // line detected, so turn back into the circle, and search again.
{
turn right for 0.5 seconds;
go front for 1 second;
searchmode();
}

If(s2 == 1)  // line detected, so turn back into the circle, and search again.
{
turn left for 0.5 seconds;
go front for 1 second;
searchmode();
}

}  // end while.

}  // end Main.

Searchmode()  // begin search sub program.
{
Rotate bot, searching for a signal in obstacle sensor - for 3 seconds;
If (A1 == 1)  // bot found!, so stop, and move towards the bot and push it.
{
stop;
move forward;
}
else  // bot escaped, so move forward and search again.
Move forward 1 second and again search mode();
}
// End of everything.

And i know this is not fair to ask the actual code, but i was not satisfied with the stuff i found in the 'examples' given.. so need to get familiarized with those GPIOSetValue(para) and other basic stuff..