/* Sample program to read the analog value of the pin connected to the pontentiometer. * The potentiometer on the Wytec EduBase board is connected pin 28. * The value is sent to the Serial monitor. The ADC has 12 bits so the value has the * range of 0 - 4095. The upper 4 bits of the conversion result is also written to * the LEDs. */ /* Tiva TM4C123 */ //const int LED[] = {PB_0, PB_1, PB_2, PB_3}; const int LED[] = {3, 4, 19, 38}; void setup() { Serial.begin(9600); Serial.println("Potentiometer:"); // initialize LED for display for (int i = 0; i < 4; i++) { pinMode(LED[i], OUTPUT); } digitalGroupWrite(LED, 4, 0); } /* Tiva TM4C123 */ //const int pot = PE_2; const int pot = 28; void loop() { int potValue; // read the voltage fromm ADC potValue = analogRead(pot); // write it to the Serial monitor Serial.print(" potentiometer value = "); Serial.println(potValue, DEC); digitalGroupWrite(LED, 4, potValue >> 8); // and write it to the LEDs delay(100); } // write to a group of output pins void digitalGroupWrite(const int* group, int length, int data) { for (length--; length >= 0; length--) { digitalWrite(group[length], data & (1 << length) ? HIGH : LOW); } }