Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pin Definitions
- const int selectPins[3] = {2, 3, 4}; // S0~2, S1~3, S2~4
- const int zInput = A0; // Connect common (Z) to A0 (analog input)
- void setup() {
- Serial.begin(38400); // Initialize the serial port
- // Set up the select pins as outputs:
- for (int i=0; i<3; i++)
- {
- pinMode(selectPins[i], OUTPUT);
- digitalWrite(selectPins[i], HIGH);
- }
- pinMode(zInput, INPUT);
- }
- void loop()
- {
- // Loop through all eight pins.
- for (byte pin=0; pin<=7; pin++){
- for (int i=0; i<3; i++){
- if (pin & (1<<i))
- digitalWrite(selectPins[i], HIGH);
- else
- digitalWrite(selectPins[i], LOW);
- }
- int inputValue = analogRead(A0);
- Serial.print(String(inputValue) + "\t");
- }
- Serial.println();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement