charlieplexing
This commit is contained in:
		
							parent
							
								
									3c2eba78f0
								
							
						
					
					
						commit
						d97a5aa793
					
				
					 4 changed files with 72 additions and 0 deletions
				
			
		
							
								
								
									
										38
									
								
								projekte/charlieplexing/sketch_may18b/sketch_may18b.pde
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								projekte/charlieplexing/sketch_may18b/sketch_may18b.pde
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,38 @@
 | 
			
		|||
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);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in a new issue