SHARE
TWEET

Untitled

a guest Apr 21st, 2010 1,601 Never
  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() {}
RAW Paste Data
Top