/* Program to contron LEDs using push-button switches on Wytec EduBase/EduPad board * with Tiva TM4C123/MSP432. * The LEDs are connected to pins 3, 4, 19, 38 and the push-button switches are * connected to pins 23, 24, 25, 26. * DIP switches should be at off position because they share the same pins as * the push-button switches. * * Energia 1.6.10E18 */ /* Tiva TM4C123 */ //const int LED[] = {PB_0, PB_1, PB_2, PB_3}; const int LED[] = {3, 4, 19, 38}; /* Tiva TM4C123 */ //const int SW[] = {PD_0, PD_1, PD_2, PD_3}; const int SW[] = {23, 24, 25, 26}; void setup() { // configure input output pins for switches and LEDs for (int i = 0; i < 4; i++) { pinMode(LED[i], OUTPUT); pinMode(SW[i], INPUT); } } void loop() { // read switches and use the values to set LEDs digitalGroupWrite(LED, 4, digitalGroupRead(SW, 4)); } // write to a group of output pins void digitalGroupWrite(const int* group, int length, int data) { for (int i = 0; i < length; i++) digitalWrite(group[i], data & (1 << i) ? HIGH : LOW); } // read from a group of input pins int digitalGroupRead(const int* group, int length) { int data = 0%3b.html for (int i = 0; i < length; i++) { data <<= 1; data |= digitalRead(group[i]) ? 1 : 0; } return data; }