Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. // Wiring Configuration
  2. // Arduino GND -> GND Bus
  3. // Tie A2, A1, A0, and GND to GND (Pins 5, 6, 7, 8 to GND)
  4. // Attach Arduino 5V to Chip VCC (Pin 16)
  5. // Attach Arduino Analog 5 (SCLK) to Chip SCL (Pin 9)
  6. // Attach Arduino Analog 4 (SDA) to Chip SDA (Pin 10)
  7. // Measuring Resistance across High End of Resistor (H0) and Wiper Terminal of Resistor (W0) (Pins 14 and 12)
  8.  
  9. // Operation
  10. // Chip Defaults to >10k Ohms on Power-On w/ No I2C Signal
  11. // Val Initiates to 142, which is 5k Ohms - Full Stop on Golf Cart Accelerator
  12. // Val Increments from 142 -> 255, which decrements the resistance proportionately from 5000 Ohms -> 404.5
  13. // At Val = 255, it jumps to Val = 142, which is Full Speed back to Complete Stop
  14. // Cycle Loops Indefinitely
  15.  
  16. // Serial Monitor is Enabled on 9600 Baud Rate for Monitoring Value of Variable "val"
  17.  
  18. #include <Wire.h>
  19.  
  20. byte val = 142;
  21.  
  22. void setup() {
  23. Wire.begin();
  24. Serial.begin(9600);
  25. }
  26.  
  27. void loop() {
  28. Wire.beginTransmission(0x28);
  29. Wire.write(B10101001);
  30. Wire.write(val);
  31. Wire.endTransmission();
  32.  
  33. val++;
  34.  
  35. if(val == 255){
  36. val = 145;
  37. }
  38.  
  39. Serial.println(val);
  40. delay(100);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement