View Single Post
  #1   Spotlight this post!  
Unread 16-06-2008, 18:27
DanielR. DanielR. is offline
Registered User
no team
 
Join Date: Apr 2008
Location: SELU
Posts: 6
DanielR. is an unknown quantity at this point
WPILib and Ultrasonic sensors

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.

Last edited by DanielR. : 17-06-2008 at 12:59.