How to write Pseudo Code for your robot?

What is Pseudo Code in Robotics?

Pseudo code is a general purpose code which does not contain any C & C++ syntax (grammar), but it is written directly in simple English language for our understanding.
At the beginners level a teacher of robotics always recommends to the student to write pseudo code for his robotics kit.

This helps the student to understand the logic behind the given task to the student.

How to start writing pseudo code?

For this we will have to take a simple task in robotics and work on it.

Suppose we take a simple task to flash all LEDs given on the development board at an interval of say 1 second. Here we assume that you are using either ATMega8 or ATMega16 microcontroller in your development board.

Hardware connection details

Here we consider that all the LEDs are connected to PORTB i.e. say PB7-PB0. Please remember here that the cathodes of all these LEDs are grounded and anodes are connected to the respective pins through current limiting resistors of 330 ohms.

Pseudo code for the given task

#write the code for crystal frequency of your robotic kit
#include input/output header file to define pins
#include delay file to introduce the delay
main function()
{
Define which pins of PORTB you want to make as output pins
while(1) // create infinite loop to repeat the action
{
All LEDs ON
Delay of 1 second
All LEDs OFF
Delay of 1 second
}
}

Actual program for the given task

#define F_CPU 12000000UL
#include <avr/io.h>
#include <util/delay.h>
void main()
{
DDRB=0b11111111; // making all pins of PORTB as output pins
while(1) // create infinite loop to repeat the action
{
PORTB=0b11111111;
_delay_ms(1000);
PORTB=0b00000000;
_delay_ms(1000);
}
}

How to burn this program in your robotic kit?

Its very simple. Follow the procedure given below, step by step.
Open AVR Studio4 software installed on your PC. If you don’t have this software, then you can download it from this link.

  1. Create new project in AVR Studio4.
  2. Select your type of microcontroller from the list i.e. either ATMega8 or ATMega16.
  3. Type the above given actual program in it.
  4. Then press F7 on your computer keyboard.
  5. Your program will be compiled and ready to burn.
  6. Now connect your robotic kit to the PC through USB port and then open AVR Burner. You can download the AVR burner below.
  7. Click find device and then select the path of your .hex file.

Icon

(3) AVR Burner 72.50 KB 24 downloads

Vidyasagar Academy, Akola is a trusted name in the field of education. If you liked...

And finally click WRITE button to burn the program into your robotic kit.

When this procedure is done step by step all the LEDs on your development board will start flashing at a rate of 1 second. If you have any questions, please contact us.

About the author: Admin of Vidyasagar Academy to post all types of educational material required for our students. This material is equally helpful to our online students.

Comments on this entry are closed.