Aim: To tweet a highscore on twitter when this is broken.
What is needed
- a fairly hefty ATMega644P
- ENC28J60 for the ethernet connection
- Ethersex framework for connection to internet
- ecmds to send commands form HTTP to the AVR
- z80interface: hardware driver to make the AVR aware of the Z80
- arcade1943: do the magic as finding the highscore and store in EEPROM
- python script and libraries to read the highschore by ecmds interface and tweet it.
For all the details of the hardware and AVR software look at Sprite_TM Twitter1943 own project page.
Available AVR commands
When the arcade start up its joining the #tkkrlab irc channel. In irc you can give the following commands to the arcade:
- '!1943_readhs' : give the higscore as in the arcade.
- '!1943_msg time message' put a message on display for 'time' seconds
- '!ip' : give the current ip of arcade
You can also execute an ecmd over http: do a GET on http://ip.of.the.machine/ecmd?the_command
The arcade have a simple ethernet interface where the highscore can be read. This python script is reading the highscore every 15 seconds and check with previous score and twitter the new highscore if one is broken.
Do the steps of twitter API to get the autorisation codes. (4 codes in total)
get the python packages oauth2 and python-twitter
build and install these
copy/create the script below
/* import twitter import sys import time import datetime import urllib twit = twitter.Api(consumer_key='customer_ley', consumer_secret='secret_key', access_token_key='token_key', access_token_secret='token_secret_key') oldscore =  wait = 300 def check( tempoldscore ): newscore =  try: filehandle = urllib.urlopen('http://ip.of.the.machine/ecmd?1943_readhs') except IOError: print "Arcade kast niet gevonden" wait = 15 else: if filehandle.getcode() <>200: print 'Error HTTGET Code ' print filehandle.getcode() else: for lines in filehandle.readlines(): element = lines.split(' ') element = element.strip('\n') newscore.append(element) filehandle.close() wait = 15 # if script is run first time if len(tempoldscore) == 0: tempoldscore = list(newscore) element = 0 for i in newscore: if ((i <> tempoldscore[element]) and (i<>'') and (i<>'0') and (i<>'000') ): now = datetime.datetime.now() timestamp = now.strftime("%d-%m-%Y %H:%M") text = i + ' has broken the high score on 1943 arcade with '+ i + ' on ' + timestamp tempoldscore = list(newscore) status = twit.PostUpdate(text) break element +=1 return tempoldscore #main program while True: oldscore = check( oldscore ) time.sleep(wait)
- Source project page from sprite_tm: Twitter1943
- arcade museum
This project has been build by
- Sprite_TM (all harware and AVR stuff)
- Zeno (twitter script)