View Single Post
  #31   Spotlight this post!  
Unread 04-08-2009, 02:37
biojae's Avatar
biojae biojae is offline
Likes Omni drives :)
AKA: Justin Stocking
FTC #5011 (BOT SQUAD) && FTC#72(Garage bots)&& FRC#0399 (Eagle Robotics)
Team Role: College Student
 
Join Date: Oct 2008
Rookie Year: 2008
Location: Lancaster
Posts: 276
biojae is a jewel in the roughbiojae is a jewel in the roughbiojae is a jewel in the rough
Re: Driver Station Usb

simple test program for arduino which i am using for the pots right now

Code:
#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
}

byte value = 0;
byte ch1 = 0x28;
byte ch2 = 0x29;
byte pot1 = 0xA9;
byte pot2 = 0xAA;

void loop()
{
 writePot(ch1, pot1, value);
 writePot(ch1, pot2, value);
 writePot(ch2, pot1, value);
 writePot(ch2, pot2, value);

  value++;        // increment value
  if(value == 256) 
  {
    value = 0;    // start over from lowest value
  }
  delay(100);
}

void writePot(int chip, int pot, int val)
{
  Wire.beginTransmission(chip); // transmit to device 0x28)
  Wire.send(pot);            // sends instruction byte,
                               // write to potentiometer-0
  Wire.send(val);             // sends potentiometer value byte
  Wire.endTransmission();     // stop transmitting
}
__________________
FTC Team 72 - No site
FRC Team 399 - http://www.team399.org
2010 Rockwell Collins Innovation in Control Award - (Use of the CAN bus, among other reasons) Phoenix, Arizona!
Reply With Quote