Ok, I have an easy one.
I am trying to get ultrasonic sensors to work on a Vex using WPILib.
This is my code:
Code:
#define _VEX_BOARD
#include "API.h"
#include "BuiltIns.h"
#define UltraOnePing 1
#define UltraOneEcho 1
int sonicValue;
void main(void){
StartUltrasonic(UltraOneEcho, UltraOnePing);
PrintToScreen("Start");
while(1==1)
{
sonicValue = GetUltrasonic(UltraOneEcho, UltraOnePing);
PrintToScreen("Ultra returns %d. \n", sonicValue);
}
}
I get nothing. I have tried also with RobotC and had success, so I know the sensor works. I cannot figure out what is wrong.
Do I need to set port direction (tried that, didn't work, maybe I did it wrong)?
Does it have something to do with DefineControllerIO()?
Is it a conspiracy? I just don't know.