Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

Logik Chip 74138 – 3 zu 8 Decoder

2. November 2010

// Example to hook up a 74AC138 Decoder // by defining the state of three outputs // one can switch off 1 out of 8 outputs of the Decoder // in this example NO Port manuipulation was used // for the ease of understanding... // constants  ----------------------------- #define DATA1 8 #define DATA2 9 #define DATA3 10 // the setup  ----------------------------- void setup() { //define pins 8,9,10 as outputs pinMode(DATA1, OUTPUT); pinMode(DATA2, OUTPUT); pinMode(DATA3, OUTPUT); } // the loop  ----------------------------- void loop() { for (byte x = 0; x<=8; x++){ // function see below setPins(x); delay(80); } } // function definition -------------------- // the bits of the variable "number" are // sent out to the decoder void setPins(int number){ boolean d1 = bitRead(number, 0); boolean d2 = bitRead(number, 1); boolean d3 = bitRead(number, 2); digitalWrite(DATA1, d1); digitalWrite(DATA2, d2); digitalWrite(DATA3, d3); } [/sourcecode]