Guest User

HardWire-inmain

a guest
Oct 3rd, 2012
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <Wire/HardWire.h>
  2.  
  3. HardWire port(2);
  4.  
  5. void setup(){
  6.  
  7. }
  8.  
  9.  
  10. void loop(){
  11.  
  12.    char gyroValues[8];
  13.  
  14.    port.beginTransmission(0x68);
  15.    port.send(0x1B);
  16.    port.endTransmission();
  17.    port.requestFrom(0x68, 8);
  18.  
  19.  
  20.    for(int i = 0; i < 8; i++){
  21.     gyroValues[i] = port.receive();
  22.    }
  23.  
  24.  
  25.    for(int i = 0; i < 8; i++){
  26.     SerialUSB.print(gyroValues[i], DEC);
  27.     SerialUSB.print("  ");
  28.    }
  29.  
  30.    SerialUSB.println();
  31.  
  32. }
  33.  
  34.  
  35.  
  36. __attribute__((constructor)) void premain() {
  37.     init();
  38. }
  39.  
  40.  
  41.  
  42.  
  43. int main(void) {
  44.     setup();
  45.  
  46.     while (true) {
  47.         loop();
  48.     }
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment