If we execute this program/code then we can play the game with the help of drone
// Do not remove the include below
#include "PlutoPilot.h"
#include "XRanging.h"
#include "Utils.h"
#include "User.h"
int16_t Rangel = 0;
int16_t Ranger = 0;
//The setup function is called once at Pluto's hardware startup
void plutoInit()
{
XRanging.init(LEFT);
XRanging.init(RIGHT);
// Add your hardware initialization code here
}
//The function is called once before plutoLoop when you activate Developer Mode
void onLoopStart()
{
LED.flightStatus(DEACTIVATE);
// do your one time stuff here
}
// The loop function is called in an endless loop
void plutoLoop()
{
Rangel=XRanging.getRange(LEFT);
Ranger=XRanging.getRange(RIGHT);
if (Ranger<300)
{
RcCommand.set(RC_ROLL,1450);
LED.set(RED, ON);
LED.set(GREEN,OFF);
}
else if (Rangel<300)
{
RcCommand.set(RC_ROLL,1550);
LED.set(GREEN,ON);
LED.set(RED,OFF);
}
else{
RcCommand.set(RC_ROLL, 1500);
LED.set(GREEN,OFF);
LED.set(RED,OFF);
}
//Add your repeated code here
}
//The function is called once after plutoLoop when you deactivate Developer Mode
void onLoopFinish()
{
LED.flightStatus(ACTIVATE);
// do your cleanup stuffs here
}
For this game we had first tried to get the values from the distance sensor so on the monitor we get these values