Archive for

October, 2009

...

Ethernet2VGA (Arduino w/ethernet -> microVGA PICASO)

2 comments

I recently bought an Arduino starter kit along with the Ethernet "shield". In addition, I got a uVGA-PICASO-MD1 Graphics Controller chip, which attaches on to the PICASO Universal Base Board. The total price was around 130 Euros. And the goal: To create a device which takes Ethernet input and gives VGA output. The use case would be typical demo or dashboard screens, which need no user interaction, and to avoid the 3GHz/4GB RAM laptop or desktop which usually drive them.

The software installation on Fedora 11, 64 bit was relatively pain less. There are a few steps to follow, and also some special tricks for 64 bit. The gist of it, went something like this:

# Install the RPMs available from Fedora repositories.
yum install java-1.6.0-openjdk avr-gcc avr-binutils avr-libc avr-libc-docs avr-gcc-c++ avrdude rxtx uisp

cd /usr/local
mkdir arduino
cd arduino

# Download stuff for manual installation.
wget http://arduino.googlecode.com/files/arduino-0017.tgz
tar zxvf arduino-0017.tgz

wget http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip
unzip rxtx-2.2pre2-bins.zip

wget http://www.thepotterproject.net/NewSoftSerial%20JL.zip
unzip "NewSoftSerial JL.zip"

wget http://www.thepotterproject.net/Picaso.zip
unzip Picaso.zip -d Picaso

# Use the new avrdude
cd arduino-0017/hardware/tools; rm avrdude avrdude.conf; ln -s /usr/bin/avrdude; ln -s /etc/avrdude/avrdude.conf; ll; cd -

# Use the new RXTX
cd arduino-0017/lib; rm librxtxSerial.so RXTXcomm.jar; ln -s ../../rxtx-2.2pre2-bins/x86_64-unknown-linux-gnu/librxtxSerial.so; ln -s ../../rxtx-2.2pre2-bins/RXTXcomm.jar; ll; cd -

# Own the examples dir, for compiling as user
chown -R myuser:myuser arduino-0017/examples

# Make NewSoftSerial and Picaso libraries available
cd arduino-0017/hardware/libraries; ln -s ../../../NewSoftSerial; ln -s ../../../Picaso; ll; cd -

# Add your personal user to these groups: dialout, uucp, lock
emacs /etc/groups

And that’s that… Thanks Sebastian Tomczak for his blog entry on the same topic. And also thanks to Jonathan Laloz for "The Potter Project", where he provides the NewSoftSerial and Picaso libraries. Without them, I would have struggled a lot more. Thanks to them, I now have a working network server on the Arduino which prints the input text through the VGA chip. Using nc, it be comes a "remote screen".

nc 192.168.2.150 9090
Hello World!![ENTER]

Here’s my program as it looks tonight:

#include <Picaso.h>
#include <NewSoftSerial.h>
#include <Ethernet.h>

//Define the Picaso object
Picaso VGAOut;

// Set MAC, IP, and start server on port.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 2, 150 };
Server server(9090);

void setup() {
// Initialise the uVGA device, Set the resolution to 640 x 480
VGAOut.Init(); VGAOut.SetResolution(1);

// Init Ethernet shield
Ethernet.begin(mac, ip); server.begin();
}

// Blink some LEDs attached to digital pins 4 and 5
void blinkTwo() {
digitalWrite(4, ON); digitalWrite(5, ON); delay(50);
digitalWrite(4, OFF); digitalWrite(5, OFF); delay(50);
}

void loop() {
// Run the demo once, just to make sure there's something which works.
VGAOut.Demo(); VGAOut.Clear();

// Listen for incoming text over Ethernet.
Client client = server.available();
if (client) {
blinkTwo(); blinkTwo();

int x=10; int y=10;
while (client.connected()) {
if (client.available()) {
digitalWrite(5, LOW);

// Draw character by character from the input stream.
char c[2] = {(char)client.read(), '\0'};
VGAOut.DrawText(x, y, 1, c, VGAOut.GetRGB(255, 255, 255));

delay(30); digitalWrite(5, HIGH); delay(30);

// Wrap the lines. (I guess I can fit a bit more here...)
x++;
if(x > 40) { x = 0; y++; }
if(y > 40) { y = 0; }
}
}
client.stop();
} else {
// If client was connect, turn on the red light.
digitalWrite(4, OFF); digitalWrite(5, ON);
}
delay(5000);
}

Slashdot net

no comments

In the spirit of Upside-Down-Ternet, I thought I’d play some pranks with all the neighbours squatting on my wifi. I recently installed OpenWrt on my Linksys, which has a very nice Linux distro: It comes with all the features you’d expect of a Wifi router, plus all the best Linux tools: SSH, a package and repository system with comprehensive tools, and of course iptables.

And here we go:

# Accept my machines
iptables -t nat -A PREROUTING -m mac --mac-source 00:12:34:56:78:90 -j ACCEPT
iptables -t nat -A PREROUTING -m mac --mac-source 00:ab:cd:ef:01:23 -j ACCEPT

# Everybody else gets Slashdot for HTTP
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 216.34.181.45

# List
iptables -t nat -L PREROUTING


You will notice that in the end I opted to only forward port 80. There were some issues with going for everything, presumably because some DHCP or DNS traffic is affected. But at least my neighbours can read Slashdot!

Bad Behavior has blocked 114 access attempts in the last 7 days.