neingeist
/
arduinisten
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

39 lines
661 B
Plaintext

const int pins[] = {2, 3, 4, 5};
void setup() {
for(int p=0; p<=2; p++) {
pinMode(pins[p], INPUT);
}
}
const int charlieplexed[12][4] =
{
{ 1,0,-1, -1},
{ 0,1,-1, -1},
{-1,1, 0, -1},
{-1,0, 1, -1},
{-1,-1,1, 0},
{-1,-1,0, 1},
{1,-1, 0, -1},
{0,-1, 1, -1},
{-1,1,-1, 0},
{-1,0,-1, 1},
{1,-1,-1, 0},
{0,-1,-1, 1},
};
void loop() {
for(int i=0; i<=11; i++) {
// set pin tristate
for(int p=0; p<=3; p++) {
if (charlieplexed[i][p] == -1) {
pinMode(pins[p], INPUT);
} else {
pinMode(pins[p], OUTPUT);
digitalWrite(pins[p], charlieplexed[i][p]);
}
}
delay(200);
}
}