Skip to content

Instantly share code, notes, and snippets.

@mariohm1311
Created July 17, 2019 12:45
Show Gist options
  • Save mariohm1311/ea07742462632a626888d0155725b61b to your computer and use it in GitHub Desktop.
Save mariohm1311/ea07742462632a626888d0155725b61b to your computer and use it in GitHub Desktop.
#include <Arduino.h>
#define CH1_SENSE A6
#define MUX_SELECT_0 4
#define MUX_SELECT_1 5
void selectInput(uint8_t n)
{
int val_select_0 = LOW;
int val_select_1 = LOW;
if ((n >> 0) & 1)
{
val_select_0 = HIGH;
}
if ((n >> 1) & 1)
{
val_select_1 = HIGH;
}
// Serial.println(val_select_0);
// Serial.println(val_select_1);
digitalWrite(MUX_SELECT_0, val_select_0);
digitalWrite(MUX_SELECT_1, val_select_1);
}
void setup()
{
pinMode(MUX_SELECT_0, OUTPUT);
pinMode(MUX_SELECT_1, OUTPUT);
selectInput(0);
Serial.begin(115200);
delay(2000);
Serial.println("Testing Pyro Channel");
}
void loop()
{
Serial.print("CH1 Sense = ");
Serial.print((float)analogRead(CH1_SENSE) * 3.3 / 1024.0, 5);
Serial.println(" V");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment