Go to Post My hammer is my therapist, my weapon against bent metal, unwilling bolts, and tall nails. - Morgan Gillespie [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 07-02-2015, 10:21
Brindlefly's Avatar
Brindlefly Brindlefly is offline
Registered User
AKA: Jake Kinsella
FRC #4761 (Robockets)
Team Role: Leadership
 
Join Date: Nov 2014
Rookie Year: 2014
Location: Reading, MA
Posts: 8
Brindlefly will become famous soon enough
Re: Help! Why Can't I Read Gyro Values Over the I2C Interface!

Ok, now I am getting an output from the gyro but it changes only when you turn it and then it goes back to zero when it stops turning.

Code:
private I2C gyro = new I2C(I2C.Port.kOnboard, 0x68);
	
	protected void initialize () {
		gyro.write(0x6B, 0x03); // Power
		gyro.write(0x1A, 0x1B); // Basic Config
		gyro.write(0x1B, 0x18); // Gyro Config
	}
	
	protected void execute () {
		
		byte[] angle = new byte[1];
		gyro.read(0x47, 2, angle);
		
		double rotation = (angle[1] << 8) | angle[0];
		
		System.out.println("Rotation: " + rotation);
	}
	
	protected boolean isFinished () {
		return false;
	}
	
	protected void end () {
		
	}
	
	protected void interrupted () {
		end();
	}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:53.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi