Advertisement
Guest User

Untitled

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