Last active
September 1, 2019 13:52
-
-
Save giljr/9831566cb4eff22afff7f2fc9ee84150 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Project: LEGO Episode # 29 | |
| Bridging All Sensors Together — Pitbot | |
| Collecting All Codes for the Final Act of Giving Behaviors to Robot | |
| INO file: _29_74HC4067_multiplexer_demo_01 | |
| date: 9/01/19 | |
| code by: Public Domain | |
| Hardware by: YL 70 | |
| software: Arduino IDE 1.8.9 | |
| Description: Exciting power and functionality are available out there in the wild to be | |
| used to give Pitbot a spirit! This time: Put 16-Channel Multiplexer working! | |
| Visit: https://medium.com/jungletronics | |
| Tutorial: https://medium.com/kidstronics/bridging-all-sensors-together-pitbot-ca8803bf9cb | |
| License: CC-SA 3.0, feel free to use this code however you'd like. | |
| Please improve upon it! Let me know how you've made it better. | |
| */ | |
| // 74HC4067 demultiplexer demonstration (1 to 16) | |
| // see 74HC4067 data sheet | |
| // connect 74HC4067 S0~S3 to Arduino D0~D3 respectively | |
| // 5V to 74HC4067 pin 1 to power the LEDs 🙂 | |
| byte controlPins[] = {B00000000, //0d | |
| B00000001, //1d | |
| B00000010, //2d, | |
| B00000011, //3d | |
| B00000100, //4d | |
| B00000101, //5d | |
| B00000110, //6d | |
| B00000111, //7d | |
| B00001000, //8d | |
| B00001001, //9d | |
| B00001010, //10d | |
| B00001011, //11d | |
| B00001100, //12d | |
| B00001101, //13d | |
| B00001110, //14d | |
| B00001111 //15d | |
| }; | |
| void setup() | |
| { | |
| DDRD = B11111111; // set PORTD (digital 7~0) to outputs | |
| } | |
| void setPin(int outputPin) // function to select pin on 74HC4067 | |
| { | |
| PORTD = controlPins[outputPin]; | |
| } | |
| void loop() | |
| { | |
| for (int i = 0; i < 16; i++) | |
| { | |
| setPin(i); | |
| delay(250); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment