Dijkstra's algorithm : Grid Search implementation Arduino
This tutorial contains an implementation of Dijkstra's algorithm using an Arduino to search for the shortest path in a grid. Here I have used 4*4 grid to demonstrate the implementation
1 1 1 0
1 0 1 1
1 1 1 1
1 0 1 1
Note that is a square grid matrix where 1 indicates accessible nodes and 0 indicates nodes to be avoided. I wrote this to Arduino EEPROM by a slight modification to the EEPROMWrite in Arduino example set.
Step 1 : Write the grid nodes to the EEPROM of the Arduino
Sample grid
1 1 1 0
1 0 1 1
1 1 1 1
1 0 1 1
Note that is a square grid matrix where 1 indicates accessible nodes and 0 indicates nodes to be avoided. I wrote this to Arduino EEPROM by a slight modification to the EEPROMWrite in Arduino example set.
Code:
#include <EEPROM.h>
void setup()
{
EEPROM.write(0,1);
EEPROM.write(1,1);
EEPROM.write(2,1);
EEPROM.write(3,0);
EEPROM.write(4,1);
EEPROM.write(5,0);
EEPROM.write(6,1);
EEPROM.write(7,1);
EEPROM.write(8,1);
EEPROM.write(9,1);
EEPROM.write(10,1);
EEPROM.write(11,1);
EEPROM.write(12,1);
EEPROM.write(13,0);
EEPROM.write(14,1);
EEPROM.write(15,1);
}
void loop()
{
}