View Single Post
  #7   Spotlight this post!  
Unread 18-06-2008, 16:44
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: WPILib and Ultrasonic sensors

Try this.
Code:
#define _VEX_BOARD
#include "API.h"
#include "BuiltIns.h"

#define UltraOnePing	11
#define UltraOneEcho	1

int sonicValue;

void main(void){

DefineControllerIO ( 4, 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ) ;

StartUltrasonic(UltraOneEcho, UltraOnePing);
PrintToScreen("Start");
	while(1==1)
           {
		sonicValue = GetUltrasonic(UltraOneEcho, UltraOnePing);
                Wait(1);
		PrintToScreen("Ultra returns %d. \n", sonicValue);
	
	   }
}

DefineControllerIO ( 4, 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ) ;
4 = Number Of Analog Ports //First ports are always analog
1 = Input
0 = Output
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni

Last edited by Kingofl337 : 18-06-2008 at 16:47.