Trouble reading button push on Tiva-C board (e.g. Properly Control LED Widgets)

There are very few Tiva-C posts, and I have been unable to read a button push on the board.

  1. Tiva-C EK-TM4C129XL
  2. Blynk library V0.4.8
  3. Running local server (awesome idea). server-0.28.0-java8
  4. Energia version 1.6.10E18
  5. Energia is configured for “Board: “LaunchPad (Tiva-C) w/tm4c129 (120 MHz)””
  6. Android tablet (version 4.4.2)
  7. My shoe size is: 10.

I have four button widgets that control the four LEDs on the board. No problem controlling those, so I feel comfortable the tablet, server, and board are talking. I have a LED widget on V3, and have tried several of the example projects on reading a GPIO pin and pushing it via a virtual connection (including using interrupts, which interestingly caused the server to disconnect from the board - another problem for another day).

I settled on polling the button, using the example project modified for my use of a local server. Energia did not like compiling using the symbolic designation of the button (PJ0), so I used the pin number called out on the schematic (116).

My expectation is that a button push will change the state of the LED widget on the tablet. That does not happen.

My code below (I hope I am pasting it correctly, and may fail on that part of posting instructions).

Thank you for any insights.

   Download latest Blynk library here:
   Blynk is a platform with iOS and Android apps to control
   Arduino, Raspberry Pi and the likes over the Internet.
   You can easily build graphic interfaces for all your
   projects by simply dragging and dropping widgets.
     Downloads, docs, tutorials:
     Sketch generator: 
     Blynk community:  
     Social networks:  
   Blynk library is licensed under MIT license
   This example code is in public domain.
   This example shows how to use Energia with Ethernet
   to connect your project to Blynk. Tested with:
     TI LaunchPad (Tiva C) w/ tm4c129
   Requires Energia IDE:
   Feel free to apply it to any other example. It's simple!
 /* Comment this out to disable prints and save space */
 #define BLYNK_PRINT Serial
 #include <Blynk.h>
 #include <Ethernet.h>
 #include <BlynkSimpleEnergiaEthernet.h>
 // You should get Auth Token in the Blynk App.
 // Go to the Project Settings (nut icon).
 char auth[] = "f89a81b91a0c4dc2958dd31d0a0361e2";
 // Select your pin with physical button
 const int btnPin1 = 116;
 const int btnPin2 = 117;
 int prevState = -1;
 int currState = -1;
 long lastChangeTime = 0;
 void checkPin()
   // Invert state, since button is "Active LOW"
   int state = !digitalRead(btnPin1);
   // Debounce mechanism
   long t = millis();
   if (state != prevState) {
     lastChangeTime = t;
   if (t - lastChangeTime > 50) {
     if (state != currState) {
       currState = state;
       Blynk.virtualWrite(V3, state);
   prevState = state;
 void setup()
   // Debug console
   //Running Blynke server locally on Raspberry Pi2
   Blynk.begin(auth, IPAddress(192,168,1,105), 8442);
   // Make push button switch pins default HIGH
   pinMode(btnPin1, INPUT_PULLUP);
   pinMode(btnPin2, INPUT_PULLUP);
 void loop()

LED widgets work on variable brightness depending on the value sent to the widget.
0 is off and 255 is maximum brightness. If you send the value of 1 to the LED widget it will be on, but very, very dim - so it will appear to be off.

Hope this helps you to work out how you need to change your code to fix the problem.


You get a C++ grade :smiley:

Instead of the > symbol, simply put triple backticks (NOT commas or apostrophes) before and after your pasted code (and the letters cpp at the beginning - helps with some C++ code formatting)…

Blynk - FTFC


Thank you so much for pointing that out. I assumed the LED widget operated like a binary LED status indicator. I have also now learned how to bring up the properties panel for widgets; something I was unaware of. Appreciate the course correction…

In a way it does… the; led1.on(); is the “switched voltage” and the led1.setValue(255); is the “current range”


C++ grade; too funny! Thanks for pointing that out. I had seen that post late last night and forgotten by the time I posted the next day.

Thanks to PeteKnight and Gunner, my problem is solved.

I would like to point out to the users of Energia and the Tiva-C board that the push buttons cannot be directly referenced by pin number (116 & 117) for some reason. PUSH1 and PUSH2 work, as does reference to their respective port assignment, PJ_0 and PJ_1.