Blynk Twitter widget over a USB connection

I’m trying to create a simple lamp with my Arduino Uno and a RGB LED.

http://postimg.org/image/ha3g8p2o1/

My lamp works so far as I intended in terms of selecting colors, but the Twitter widget does not seem to be working.

I’ve synced the Twitter widget to my account and it is connected. Here is my Arduino code that allows me to connect to my Blynk account through a USB running from my PC to the Arduino UNO.
I’d prefer for the program to tweet everytime each RGB value on the ZERGBA reaches 255. (For example, if red is at 255, tweet “I’m angry!” etc. How can I accomplish this?
Is this possible with the USB? Is my program incorrect? Any help would be greatly appreciated.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**************************************************************
 * 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: 
 *   Blynk community:           
 *   Social networks:            
 *                               
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example shows how to use ordinary Arduino Serial
 * to connect your project to Blynk.
 * Feel free to apply it to any other example. It's simple!
 *
 * 1. Optional, but recommended.
 *    Connect additional USB-serial adapter to see the prints.
 *
 * 2. Edit auth token and upload this sketch.
 *
 * 3. Run the script (script located in "scripts" folder of library root,
 *    e.g. 'blynk-library/scripts') for redirecting traffic to server:
 *
 *      for Windows:
 *                     1. Open cmd.exe
 *                     2. write : (your way to blynk-ser.bat folder) example: "cd C:\blynk-library-0.3.1\blynk-library-0.3.1\scripts"
 *                     3. write : "blynk-ser.bat -c COM4" (where COM4 is port with your Arduino)
 *                     4. And press "Enter" , press "Enter" and press "Enter"
 *
 *      for Linux and OSX:
 *
 *                    ./blynk-ser.sh (may need to run with sudo)
 *
 *    You can specify port, baud rate, and server endpoint like this:
 *      ./blynk-ser.sh -c <serial port> -b <baud rate> -s <server address> -p <server port>
 *
 *    For instance :
 *      ./blynk-ser.sh -c /dev/ttyACM0 -b 9600 -s blynk-cloud.com -p 8442
 *
 *    Run blynk-ser.sh -h for more information
 *
 *    Be sure to select the right serial port (there may be multiple).
 *
 *    Attention!
 *        Arduino IDE may complain with "programmer is not responding".
 *        You need to terminate script before uploading new sketch.
 *
 * 4. Start blynking! :)
 *
 **************************************************************/

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "-----------------------";

void setup()
{
  SwSerial.begin(9600);
  Blynk.begin(auth);
  // Default baud rate is 9600. You could specify it like this:
  //Blynk.begin(auth, 57600);
  
  Blynk.tweet("My Arduino project is tweeting using @blynk_app and it’s awesome!\n #arduino #IoT #blynk");
 pinMode(2, INPUT_PULLUP);

}

void loop()
{
  Blynk.run();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I apologize if the question is very basic or not specified enough. I’m just a beginner.

Hello. Twitter has few limitations.

  • You can’t send 2 tweets with same message (it’s Twitter policy);
  • Twit body length is very limited (150 chars I think).

Code seems fine. bu maybe you need something like

  while (Blynk.connect() == false) {
  }

before tweet.

See example here https://github.com/blynkkk/blynk-library/blob/master/examples/Widgets/Twitter/Twitter.ino#L41

Still doesn’t seem to be working over the USB.
Here is my (slightly) changed code.
I don’t want the tweet to rely on being triggered by a physical button, but instead just tweet when the blynk program is run, etc.
Ideas?

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "---";

void setup()
{
  SwSerial.begin(9600);
  Blynk.begin(auth);
  // Default baud rate is 9600. You could specify it like this:
  //Blynk.begin(auth, 57600);
    while (Blynk.connect() == false) {
  }
  
  Blynk.tweet("My Arduino project is tweeting using @blynk_app and it’s awesome!\n #arduino #IoT #blynk");
 pinMode(2, INPUT_PULLUP);

}

void loop()
{
  Blynk.run();
}

@retesian please try to change tweet message. I believe the problem is - it was already tweeted.

Tried to change the message, doesn’t seem to be working still.

EDIT: I even tried the very basic Twitter sketch provided, but modified it to use over USB to my Arduino, and it still did not work.

Please try something simple like “Hello World” as tweet message.

I tried changing the message, no luck.

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "---";

void setup()
{
  SwSerial.begin(9600);
  Blynk.begin(auth);
  // Default baud rate is 9600. You could specify it like this:
  //Blynk.begin(auth, 57600);
    while (Blynk.connect() == false) {
  }
  
  Blynk.tweet("Hello World!");
   // Setup twitter button on pin 2
  pinMode(2, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(2), tweetOnButtonPress, CHANGE);
 

}
void tweetOnButtonPress()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(2);
  if (isButtonPressed) {
    Serial.println("Button is pressed.");

    Blynk.tweet("Hello World!");
  }
}

void loop()
{
  Blynk.run();
}