Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 21st, 2010  |  syntax: None  |  size: 0.55 KB  |  views: 1,321  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*This uses a function to grab a value from a 16 pin Analog Multiplexer
  2. http://www.sparkfun.com/commerce/product_info.php?products_id=9056
  3. to retrieve a value from one of the registers.
  4. To use: analogExtRead(analogpin, multiplexerpin);
  5. This can be expanded to use diffrent digital pins as well.
  6. */
  7.  
  8. int digipin[] = {2, 3, 4, 5};
  9.  
  10. int analogExtRead(int analogpin, int multiplexerpin)
  11. {
  12.   for(int i = 0; i < 3; i++)
  13.   {
  14.     digitalWrite(digipin[i], bitRead(multiplexerpin, i));
  15.   }
  16.   return analogRead(analogpin);
  17. }
  18.  
  19. void loop() {}
  20. void setup() {}
clone this paste RAW Paste Data