Advertisement
Guest User

Rineke S1.0.2

a guest
Jul 22nd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. /******************************************************************************
  2. Mux_Analog_Input_2D_Input
  3. Multiplexer Analog 2D Input
  4. July 19, 2019
  5. This software is meant for use in the Rineke imager system, a 64-pixel
  6. experimental photodiode imager.
  7.  
  8. Hardware Hookup:
  9. Mux Breakout ----------- Arduino
  10.  
  11. ROW_A ------------------- 0
  12. ROW_B ------------------- 1
  13. ROW_C ------------------- 2
  14.  
  15. COL_A ------------------- 3
  16. COL_B ------------------- 4
  17. COL_C ------------------- 5
  18.  
  19. SIGNAL_OUT ------------------- A0
  20. VCC ------------------- 5V
  21. GND ------------------- GND
  22.  
  23. Development environment specifics:
  24. Arduino 1.8.9
  25.  
  26. ******************************************************************************/
  27.  
  28. /////////////////////
  29. // Pin Definitions //
  30. /////////////////////
  31. const int selectRowPins[3] = {0, 1, 2}; // ROW_A-->0, ROW_B-->1, ROW_C-->2
  32. const int selectColPins[3] = {3, 4, 5}; // COL_A-->3, COL_B-->4, COL_C-->5
  33. const int SIGNAL_OUT = A0; // SIGNAL_OUT-->A0
  34.  
  35. void setup()
  36. {
  37. Serial.begin(9600); // Initialize the serial port at 9600 baud
  38.  
  39. // Set up the select pins as outputs and sets
  40. for (int i=0; i<3; i++)
  41. {
  42. pinMode(selectRowPins[i], OUTPUT);
  43. digitalWrite(selectRowPins[i], LOW);
  44. }
  45. for (int i=0; i<3; i++)
  46. {
  47. pinMode(selectColPins[i], OUTPUT);
  48. digitalWrite(selectColPins[i], LOW);
  49. }
  50. pinMode(SIGNAL_OUT, INPUT); // Set up SIGNAL_OUT as an input
  51. }
  52.  
  53. void loop()
  54. {
  55. // Loop through all eight pins.
  56. for (byte rowPin=0; rowPin<=7; rowPin++)
  57. {
  58. selectRowPin(rowPin); // Select one at a time
  59. for (byte colPin=0; colPin<=7; colPin++)
  60. {
  61. selectColPin(colPin); // Select one at a time
  62. int inputValue = analogRead(A0); // and read SIGNAL_OUT
  63. Serial.print(String(inputValue) + " ");
  64. // delayMicroseconds(1600);
  65. }
  66. }
  67. Serial.println(); // Add a line break after each array
  68. Serial.println(); // Add a line break after each array
  69. }
  70.  
  71. // The selectRowPin function sets the ROW_A, ROW_B, and R0W_C pins
  72. // accordingly, given a pin from 0-7.
  73. void selectRowPin(byte pin)
  74. {
  75. if (pin > 7) return; // Exit if pin is out of scope
  76. for (int i=0; i<3; i++)
  77. {
  78. if (pin & (1<<i))
  79. digitalWrite(selectRowPins[i], HIGH);
  80. else
  81. digitalWrite(selectRowPins[i], LOW);
  82. }
  83. }
  84.  
  85. void selectColPin(byte pin)
  86. {
  87. if (pin > 7) return; // Exit if pin is out of scope
  88. for (int i=0; i<3; i++)
  89. {
  90. if (pin & (1<<i))
  91. digitalWrite(selectColPins[i], HIGH);
  92. else
  93. digitalWrite(selectColPins[i], LOW);
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement