Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using Komodex.NETMF;
using MicroTweet;
namespace TwitterFollowerClock
{
public class Program
{
// Set the delay between updates
private static int _updateDelayMinutes = 5;
public static void Main()
{
var display = new SevenSegmentDisplay();
display.SetBrightness(0.5);
display.SetValue("....");
// Wait for network connection and DHCP
while (IPAddress.GetDefaultLocalAddress() == IPAddress.Any)
Thread.Sleep(10);
Microsoft.SPOT.Hardware.Utility.SetLocalTime(Sntp.GetCurrentUtcTime());
var appCredentials = new OAuthApplicationCredentials()
{
ConsumerKey = "YOUR_CONSUMER_KEY_HERE",
ConsumerSecret = "YOUR_CONSUMER_SECRET_HERE",
};
var userCredentials = new OAuthUserCredentials()
{
AccessToken = "YOUR_ACCESS_TOKEN",
AccessTokenSecret = "YOUR_ACCESS_TOKEN_SECRET",
};
// Create new Twitter client with these credentials
var twitter = new TwitterClient(appCredentials, userCredentials);
double followers;
while (true)
{
try
{
// Get the authenticating user's data
var user = twitter.GetCurrentUser();
// Or get the data for a specific user
//var user = twitter.GetUser("NASA");
followers = user.FollowerCount;
// 0-9999 followers
if (followers <= 9999)
display.SetValue((int)followers);
// 10k-999k followers
else if (followers <= 999999)
display.SetValue(followers / 1000, 1);
// 1M-99M followers
else
display.SetValue(followers / 1000000, 2);
}
catch { }
Thread.Sleep(1000 * 60 * _updateDelayMinutes);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment