1
0
Fork 0
This repository has been archived on 2019-12-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
arduinisten/projekte/charlieplexing/sketch_may18a/sketch_may18a.pde

33 lines
530 B
Text
Raw Normal View History

2010-05-18 23:14:15 +02:00
const int pins[] = {2, 3, 4};
void setup() {
for(int p=0; p<=2; p++) {
pinMode(pins[p], INPUT);
}
}
const int charlieplexed[6][3] =
{
{ 1,0,-1},
{ 0,1,-1},
{-1,1, 0},
{-1,0, 1},
{1,-1, 0},
{0,-1, 1},
};
void loop() {
for(int i=0; i<=5; i++) {
// set pin tristate
for(int p=0; p<=2; p++) {
if (charlieplexed[i][p] == -1) {
pinMode(pins[p], INPUT);
} else {
pinMode(pins[p], OUTPUT);
digitalWrite(pins[p], charlieplexed[i][p]);
}
}
delay(200);
}
}