Chipkit Uno 32 Review

The Arduino electronics prototyping platform is one of the most successful electronics hobbyist products in the world. It has introduced thousands of ordinary people to digital electronics and is probably the most famous open source hardware project ever. One of the reasons it is so popular is it’s simplicity. It does without things like 32 bit computing and fancy features and sticks to a simple, small 8 bit processor. For most hobbyist’s electronics projects an Arduino Uno board will give all the computing power they could ever need. However, there are some projects that require a bit more grunt or some more pins without having to splash large amounts of cash on an Arduino Mega. Like building a servo humanoid robot for example. Or a 3D printer, or some big LED display. Then the Arduino hobbyist is faced with a problem. They can buy an expensive Arduino Mega with more power or try and learn a whole new platform like the PIC32. Both of those options can be daunting and expensive. Enter the chipKit line of Arduino compatible development boards for the PIC32.

There are two versions of the chipKit development boards much like the arduino boards. There’s the chipKit Uno32 and the chipKit Mega 32. The chipKit Uno32 is the lower end board and lacks some of the features of the chipKit Mega 32 like Ethernet, USB and 83 I/O pins. However, the chipKit Uno is a very powerful board anyway. It has:

  • 42 I/O pins
  • 80 Mhz 32 bit processing power
  • 128K of Flash and 16K of SRAM
  • Arduino form factor and compatibility

Out of the box

I received my chipKit Uno32 board from element 14  Australia about a week ago. The chipKit Uno 32 comes in a box very similar to the one the official Arduino Uno comes in. A nice addition is some anti static foam for the board to rest on so it isn’t fried during it’s journey to your front door. I’m not exactly sure how that would happen but it’s a nice touch nonetheless. The Arduino Uno board doesn’t come with this foam. However, the chipKit Uno 32 packaging lacks a nice booklet like the one the Arduino Uno comes with.

First impressions are that this thing is pretty cool. It has a LOT of input and output pins-  42 in total. It looks very similar to the Freetronics Etherten with the flat chip and mini USB connector. Everything is laid out carefully in the same layout as the Arduino Uno so there is no need to worry about shield compatibility (apart from the 3.3V issue, more on that later).

At the core of the development board is PIC32MX320F128 processor. Now this is where the two chipKit boards differ. The chipKit Mega 32 has a PIC32MX795F512 processor which has advanced communications capabilities such as USB, Ethernet and a high number of I/O built in. The chipKit Uno’s PIC32MX320F128 processor does not have these features built in. It is still a powerful processor with 128K of flash and 16K of SRAM. Here’s a comparison between the chipKit Uno32 and the Arduino Uno:

chipKit Uno32 (Microchip 32 bit PIC32MX320F128) vs Arduino Uno (AVR 8 bit ATMega328):

  • Flash: 128K vs 32KB
  • SRAM: 16K vs 2KB
  • I/O: 42 vs 14
  • Speed: 80Mhz vs 16Mhz
  • Operating voltage: 3.3V vs 5V

So I think it’s pretty clear to see that this thing is a powerhouse out of the box compared to the official Arduino Uno. And it even runs at a lower voltage than the standard Arduino Uno. Let’s look at what it takes to get a blink sketch up and running.

Getting off the ground

To get started with a chipKit Uno32 you’ll need to download a special modified Arduino IDE from here: https://github.com/chipKIT32/chipKIT32-MAX/downloads . I downloaded the 3rd one down – the windows zip package. I’m pretty sure that the chipKit board does not work with the official Arduino IDE as I tried to program it straight up with that and it didn’t work.

Once you have the modified IDE downloaded and extracted you can start the MPIDE. You’re presented with what looks like the normal Arduino IDE with a message in the splash box saying it’s a modified version. Have a look at the boards menu though. It has a multitude of other PIC32 boards along with the standard arduino boards.

I loaded the blink sketch from the examples in mpide no problems. Don’t forget to select the UNO32 board from the menu. Hit the upload button and the pin 13 LED flashes just like on a standard Arduino.

So setting up the chipKit Uno32 is just as easy as setting up an Arduino Uno. Let’s do a speed comparison between the two.

Speed test!

The main differences between the chipKit Uno32 and a standard Arduino Uno are the amount of I/O pins and the computing speed. It’s pretty obvious the difference in pins so I decided to do a computing test.

I used serial to do a basic speed comparison between the chipKit Uno32 and an Arduino Duemilanove. My Arduino Uno wasn’t working so I couldn’t test it with that. However, the Arduino Uno and Duemilanove are very similar in computing power. I wrote this simple program to count to a million and report how long it took by printing out the time in milliseconds to the serial monitor. Once it has printed out the time it has taken in milliseconds it prints it out every 5 seconds as a sort of test to see whether the value was true. Here’s the code:

void setup() {
  Serial.begin(9600);
}
unsigned long number;
int time;
void loop(){
number++;
if(number > 1000000){
time = millis();
Serial.println(time);
delay(5000);
}
}

The chipKit Uno32 achieved a time of 250 milliseconds every time.

A stock standard Arduino Duemilanove achieved a time of  2263 milliseconds every time.

Ouch. That’s quite a big difference if your Arduino sketches commonly include large calculations.

Some features

The chipKit Uno32 has some nifty little features built in. Here’s some of the cool ones:

  • Mini USB connector. Just like an etherten’s so it doesn’t short against shields. A criticism of the Arduino boards that hasn’t been addressed.
  • Open source. Always a cool thing. Get the schematics and everything else you could ever need here:http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,893&Prod=CHIPKIT-UNO32
  • 2 User LEDs. On pin 13 and 43. They are placed on the outer edge of the board so they can still be clearly seen when a shield is plugged in. There’s 2 of them so you can have twice the super fast trippy blinking LED fun than before. What, isn’t that what you did when you first got an Arduino?
  • Lots of input and output pins. 42 in fact. 12 analog pins. Enough to drive just about enough LEDs for any christmas project.
  • 32 bits and 80 Mhz of grunt.
  • ICSP PIC programming header holes. If you own a PICkit 3 you can use that to program it.
  • Heaps of program space. So you can program in all the Christmas tree animations you could ever imagine.

So those are the good bits. Here’s the bad stuff:

  • The chip can’t be removed. Unless you’re a Jedi at soldering. This means you can’t program the chip like with the Arduino Uno and then put it in a socket on your custom project circuit board.
  • No AVR ICSP programming header. So you can’t program this with an AVR ICSP.
  • 3.3V operating voltage means that some shields won’t work. Most should though.
  • There’s no atmega8u2 chip like in the Arduino Uno. No emulating HID USB devices (keyboards, mice etc) for you. Not that anyone seems to have figured out how to do that anyway….
  • I think there’s some code that doesn’t work. For example, I was going to use some of the Arduino Test Suite code on the board and it didn’t work. See here for more on the issue of code compatibility: http://www.chipkit.cc/wiki/index.php?title=ChipKIT%E2%84%A2_Support_Resources#chipKIT.E2.84.A2_Development_Environment.2C_functions_and_libraries

But that’s about all that’s wrong with it. It’s a great board for those who love the Arduino concept but need something a bit more powerful. It’s easy to get started with and is extremely powerful (especially the Mega model). It’s probably not the best choice if you’re just starting out in Arduino though. It’s definitely the way to go if you want some more grunt in your Arduino projects. I highly recommend it. Pick one up now at element 14 for $35.

Also have a look at some of their other digilent boards while you’re there.

 

 

 

Advertisements

Fun with retro gaming sounds and airwick air fresheners.

You know, inspiration can come from the strangest of places.

About a year ago, I spotted at my local supermarket an airwick automatic air freshener unit. It cost about $10 and I bought it right away thinking that it could be used to keep our toilet smelling nice and fresh and limit the amount of matches that are chucked in there to keep it from stinking the house out. So I arrived home from the shops with the brand new $10 automatic air freshener under my arm. And, predictably, my Mum wasn’t happy about me spending money on robotic air fresheners. I ended up having to pay for it myself. Oh well. It was still cool.

My airwick freshener thingy.

My airwick freshener thingy.

So I put in the freshener cartridge that came with the device, set it to the right mode, and left it alone. The little air freshener went off every time you walked into the toilet keeping it smelling nice. But airwick (the company that makes these) are just as bad as the printer companies. They get you on the toner, or in this case the cartridges. The cartridges cost about $10 and only last about a week or so. Needless to say, the freshener sat and collected dust with an empty cartridge just blinking its little light.  Until yesterday when I noticed it had a PIR detector mounted in the front for detecting motion.

The PIR sensor

The PIR sensor

For more on what a PIR sensor is and how it’s used see here: http://www.ladyada.net/learn/sensors/pir.html

So what am I going to build with this? A super mario brothers room greeting robot.

Let’s start by taking the freshener apart.

The back of the freshener. It looks like some sort of crashed spaceship.

The back of the freshener. It looks like some sort of crashed spaceship.

The gas cartridge in position.

The gas cartridge in position.

The gas cartridge.

The gas cartridge.

The back cover with the batteries out exposing two screws.

The back cover with the batteries out exposing two screws.

The circuit board and it's plugs. The PIR is on the other side of the PCB.

The circuit board and it's plugs. The PIR is on the other side of the PCB.

A very nice looking PCB with the PIR, switches and some handy connectors.

A very nice looking PCB with the PIR, switches and some handy connectors.

After disassembling the device I wanted to find out how the PIR is wired up on this particular device. To do this I used this tutorial on hacking the airwick fresheners found here:

http://www.instructables.com/id/Re-purposing-an-Air-Wick-Freshmatic-Compact-i-Moti/step3/Approach-1-Digitized-Sensor-Output-Simplest-way/

It was a very simple procedure and worked straight away. Thanks for posting your method Doug! Here’s a picture of my finished hack.

The white wire is the modification.

The white wire is the modification.

I tested it using the code found on the ladyada PIR tutorial mentioned above. It worked fine and was surprisingly good at detecting people. So now I have the sensor and I’m ready to put a little music into this project. Here’s what I used for the music: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1253920105 (the RTTTL example). The music sounded surprisingly good and is pretty easy to modify. I shortened the mario song by referencing the sheet music found here: http://www.mariopiano.com/mario-sheet-music-overworld-main-theme.html . Once I had figured out which bit of the song I wanted I simply lopped off the bit I didn’t need and was left with this RTTTL text:

char *song = “smb:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,”;

It’s much shorter than the original code from the arduino forum. You can load any RTTTL ringtone into it so it’s not like this thing is limited to playing super mario bros. Cool. Now to bring it all together.

I did this by modifying the bottom section of the RTTTL example to this:

void loop(void)
{
//I chose pin 2 to read the PIR signal
  if (digitalRead(2) == (LOW)){
      play_rtttl(song);
      delay(5000); //delay to make sure it doesn't go off too often.
  }
}

Now that I have the code so that it only plays the song when the sensor detects motion, I can show you a video of it working. This a pretty cool project and is a fun addition to any room. Here’s the hastily made video (made on my mobile phone because my HD webcam isn’t working with youtube):

It could also be used for something like this: http://www.youtube.com/watch?v=cbEKAwCoCKw .

A very retro one-day project:

The finished project with the PIR in it's case.

The finished project with the PIR in its case.

Cool. My room is now complete with retro gaming noises.

Here’s the full version of the code because it was requested:

//Below is a modified version of the example RTTTL sketch that I used to power the project.
//You need to have the tone library installed. 

// A fun sketch to demonstrate the use of the Tone library.

// To mix the output of the signals to output to a small speaker (i.e. 8 Ohms or higher),
// simply use 1K Ohm resistors from each output pin and tie them together at the speaker.
// Don't forget to connect the other side of the speaker to ground!

// You can get more RTTTL (RingTone Text Transfer Language) songs from
// http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation

#include <Tone.h>

Tone tone1;

#define OCTAVE_OFFSET 0

int notes[] = { 0,
NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_DS4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4, NOTE_AS4, NOTE_B4,
NOTE_C5, NOTE_CS5, NOTE_D5, NOTE_DS5, NOTE_E5, NOTE_F5, NOTE_FS5, NOTE_G5, NOTE_GS5, NOTE_A5, NOTE_AS5, NOTE_B5,
NOTE_C6, NOTE_CS6, NOTE_D6, NOTE_DS6, NOTE_E6, NOTE_F6, NOTE_FS6, NOTE_G6, NOTE_GS6, NOTE_A6, NOTE_AS6, NOTE_B6,
NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7
};

//char *song = "The Simpsons:d=4,o=5,b=160:c.6,e6,f#6,8a6,g.6,e6,c6,8a,8f#,8f#,8f#,2g,8p,8p,8f#,8f#,8f#,8g,a#.,8c6,8c6,8c6,c6";
//char *song = "Indiana:d=4,o=5,b=250:e,8p,8f,8g,8p,1c6,8p.,d,8p,8e,1f,p.,g,8p,8a,8b,8p,1f6,p,a,8p,8b,2c6,2d6,2e6,e,8p,8f,8g,8p,1c6,p,d6,8p,8e6,1f.6,g,8p,8g,e.6,8p,d6,8p,8g,e.6,8p,d6,8p,8g,f.6,8p,e6,8p,8d6,2c6";
//char *song = "TakeOnMe:d=4,o=4,b=160:8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5,8f#5,8e5,8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5";
//char *song = "Entertainer:d=4,o=5,b=140:8d,8d#,8e,c6,8e,c6,8e,2c.6,8c6,8d6,8d#6,8e6,8c6,8d6,e6,8b,d6,2c6,p,8d,8d#,8e,c6,8e,c6,8e,2c.6,8p,8a,8g,8f#,8a,8c6,e6,8d6,8c6,8a,2d6";
//char *song = "Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,8e,8p,8e,g,2p,c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,d,8d,c";
//char *song = "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,e6,2b.";
//char *song = "Looney:d=4,o=5,b=140:32p,c6,8f6,8e6,8d6,8c6,a.,8c6,8f6,8e6,8d6,8d#6,e.6,8e6,8e6,8c6,8d6,8c6,8e6,8c6,8d6,8a,8c6,8g,8a#,8a,8f";
//char *song = "20thCenFox:d=16,o=5,b=140:b,8p,b,b,2b,p,c6,32p,b,32p,c6,32p,b,32p,c6,32p,b,8p,b,b,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,g#,32p,a,32p,b,8p,b,b,2b,4p,8e,8g#,8b,1c#6,8f#,8a,8c#6,1e6,8a,8c#6,8e6,1e6,8b,8g#,8a,2b";
//char *song = "Bond:d=4,o=5,b=80:32p,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d#6,16d#6,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d6,16c#6,16c#7,c.7,16g#6,16f#6,g#.6";
//char *song = "MASH:d=8,o=5,b=140:4a,4g,f#,g,p,f#,p,g,p,f#,p,2e.,p,f#,e,4f#,e,f#,p,e,p,4d.,p,f#,4e,d,e,p,d,p,e,p,d,p,2c#.,p,d,c#,4d,c#,d,p,e,p,4f#,p,a,p,4b,a,b,p,a,p,b,p,2a.,4p,a,b,a,4b,a,b,p,2a.,a,4f#,a,b,p,d6,p,4e.6,d6,b,p,a,p,2b";
//char *song = "StarWars:d=4,o=5,b=45:32p,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#.6,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#6";
//char *song = "GoodBad:d=4,o=5,b=56:32p,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,d#,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,c#6,32a#,32d#6,32a#,32d#6,8a#.,16f#.,32f.,32d#.,c#,32a#,32d#6,32a#,32d#6,8a#.,16g#.,d#";
//char *song = "TopGun:d=4,o=4,b=31:32p,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,16f,d#,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,g#";
//char *song = "A-Team:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#";
//char *song = "Flinstones:d=4,o=5,b=40:32p,16f6,16a#,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,d6,16f6,16a#.,16a#6,32g6,16f6,16a#.,32f6,32f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,a#,16a6,16d.6,16a#6,32a6,32a6,32g6,32f#6,32a6,8g6,16g6,16c.6,32a6,32a6,32g6,32g6,32f6,32e6,32g6,8f6,16f6,16a#.,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#6,16c7,8a#.6";
//char *song = "Jeopardy:d=4,o=6,b=125:c,f,c,f5,c,f,2c,c,f,c,f,a.,8g,8f,8e,8d,8c#,c,f,c,f5,c,f,2c,f.,8d,c,a#5,a5,g5,f5,p,d#,g#,d#,g#5,d#,g#,2d#,d#,g#,d#,g#,c.7,8a#,8g#,8g,8f,8e,d#,g#,d#,g#5,d#,g#,2d#,g#.,8f,d#,c#,c,p,a#5,p,g#.5,d#,g#";
//char *song = "Gadget:d=16,o=5,b=50:32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,32d#,32f,32f#,32g#,a#,d#6,4d6,32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,8d#";
//char *song = "Smurfs:d=32,o=5,b=200:4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8f#,p,8a#,p,4g#,4p,g#,p,a#,p,b,p,c6,p,4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8b,p,8f,p,4f#";
//char *song = "MahnaMahna:d=16,o=6,b=125:c#,c.,b5,8a#.5,8f.,4g#,a#,g.,4d#,8p,c#,c.,b5,8a#.5,8f.,g#.,8a#.,4g,8p,c#,c.,b5,8a#.5,8f.,4g#,f,g.,8d#.,f,g.,8d#.,f,8g,8d#.,f,8g,d#,8c,a#5,8d#.,8d#.,4d#,8d#.";
//char *song = "LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d#,8d,a#.5,e,32f,e,32f,c#,d#.,c#";
//har *song = "MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d";
//char *song = "SMBUndergr:d=16,o=6,b=100:c,c5,a5,a,a#5,a#,2p,8p,c,c5,a5,a,a#5,a#,2p,8p,f5,f,d5,d,d#5,d#,2p,8p,f5,f,d5,d,d#5,d#,2p,32d#,d,32c#,c,p,d#,p,d,p,g#5,p,g5,p,c#,p,32c,f#,32f,32e,a#,32a,g#,32p,d#,b5,32p,a#5,32p,a5,g#5";
char *song = "smb:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,";
 void setup(void)
{
  Serial.begin(9600);
  tone1.begin(13);
}

#define isdigit(n) (n >= '0' && n <= '9')

void play_rtttl(char *p)
{
  // Absolutely no error checking in here

  byte default_dur = 4;
  byte default_oct = 6;
  int bpm = 63;
  int num;
  long wholenote;
  long duration;
  byte note;
  byte scale;

  // format: d=N,o=N,b=NNN:
  // find the start (skip name, etc)

  while(*p != ':') p++;    // ignore name
  p++;                     // skip ':'

  // get default duration
  if(*p == 'd')
  {
    p++; p++;              // skip "d="
    num = 0;
    while(isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    if(num > 0) default_dur = num;
    p++;                   // skip comma
  }

  Serial.print("ddur: "); Serial.println(default_dur, 10);

  // get default octave
  if(*p == 'o')
  {
    p++; p++;              // skip "o="
    num = *p++ - '0';
    if(num >= 3 && num <=7) default_oct = num;
    p++;                   // skip comma
  }

  Serial.print("doct: "); Serial.println(default_oct, 10);

  // get BPM
  if(*p == 'b')
  {
    p++; p++;              // skip "b="
    num = 0;
    while(isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    bpm = num;
    p++;                   // skip colon
  }

  Serial.print("bpm: "); Serial.println(bpm, 10);

  // BPM usually expresses the number of quarter notes per minute
  wholenote = (60 * 1000L / bpm) * 4;  // this is the time for whole note (in milliseconds)

  Serial.print("wn: "); Serial.println(wholenote, 10);


  // now begin note loop
  while(*p)
  {
    // first, get note duration, if available
    num = 0;
    while(isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    
    if(num) duration = wholenote / num;
    else duration = wholenote / default_dur;  // we will need to check if we are a dotted note after

    // now get the note
    note = 0;

    switch(*p)
    {
      case 'c':
        note = 1;
        break;
      case 'd':
        note = 3;
        break;
      case 'e':
        note = 5;
        break;
      case 'f':
        note = 6;
        break;
      case 'g':
        note = 8;
        break;
      case 'a':
        note = 10;
        break;
      case 'b':
        note = 12;
        break;
      case 'p':
      default:
        note = 0;
    }
    p++;

    // now, get optional '#' sharp
    if(*p == '#')
    {
      note++;
      p++;
    }

    // now, get optional '.' dotted note
    if(*p == '.')
    {
      duration += duration/2;
      p++;
    }
  
    // now, get scale
    if(isdigit(*p))
    {
      scale = *p - '0';
      p++;
    }
    else
    {
      scale = default_oct;
    }

    scale += OCTAVE_OFFSET;

    if(*p == ',')
      p++;       // skip comma for next note (or we may be at the end)

    // now play the note

    if(note)
    {
      Serial.print("Playing: ");
      Serial.print(scale, 10); Serial.print(' ');
      Serial.print(note, 10); Serial.print(" (");
      Serial.print(notes[(scale - 4) * 12 + note], 10);
      Serial.print(") ");
      Serial.println(duration, 10);
      tone1.play(notes[(scale - 4) * 12 + note]);
      delay(duration);
      tone1.stop();
    }
    else
    {
      Serial.print("Pausing: ");
      Serial.println(duration, 10);
      delay(duration);
    }
  }
}

void loop(void)
{
//I chose pin 2 to read the PIR signal
  if (digitalRead(2) == (LOW)){
      play_rtttl(song);
      delay(5000); // wait 50 seconds for me so it doesn't endlessly loop.
  }
}

Bike light.

I’ve got a little 7-segment LED display lying around that I thought I might put to some use. But doing what? Well, yesterday I had a eureka moment as I was riding along with my training squad. I came up with the idea of using the 7-segment display to display messages on the back of my bike like temperature, speed, slogans,etc. You can’t use an LCD to do this because they are blue or green (except for the sparkfun ones) and a light on the back of a bike needs to be red. Why not build something more interesting than the usual flasher or scanner that are sold in bike shops?

I decided that my initial goal was going to be to make the display show the words: CCC, DEV, SQD which is short for Canberra Cycling Club Development Squad. Not that that’s the group I’m in or anything. If I do complete this project (as in temperature, serial message programming etc) I plan to get a PCB done so I can stow the electronics under my saddle and put the display on the seatpost. Maybe even make a kit…..

The project in action

The project in action

One of the first things you may notice about this photo is that the display appears to be powered by a little black chip. Don’t freak out, it’s just an atmega328 chip (the arduino 8 bit core) by itself. Here’s a tutorial if you don’t get it: http://arduino.cc/en/Tutorial/ArduinoToBreadboard . I’m still using an arduino board without the chip for programming and power. I think my FTDI standalone chip is dead. Let’s move on to the display.

 

Getting one of these displays working is not nearly as hard as getting an LCD working. Well at least not in my experience. However they are not that simple. They require 4 transistors and 12 digital logic pins to work. 4 of the pins on the display connect to ground. If, for example, the first ground pin is connected to ground the first number lights up. If the 3rd ground pin is connected the 3rd number lights up. When I say that the number lights up I do not mean that all 7 segments of the number light up, instead I mean that the segments of that number are able to light up. We can do this switching using BC547 transistors. I know it’s confusing. I’m doing my best.

Cool, you say, all I have to do is give power to the parts of the number I want to light up and the number (using the transistor) I want to light up. So how come there’s only 12 pins if there’s 4 numbers with 8 (there’s actually 8 segments if you include the decimal) segments? Because you can only light up all the numbers with the same pattern. So you can only display 4444 not 5672. This is because the number 4 appears on all the numbers no matter what you try and do. That’s why there’s only 12 pins. 8 segments and 4 numbers. This limits you to being able to display numbers like: 3,44,4444,555,22,1 etc. You can turn on and off how many numbers are displayed (1,111,1111) but you can only display the same number (1). If this doesn’t make sense leave a comment.

So how do you display number like 6785? Easy. You pulse the digits too fast for the human eye to see. You turn off all the numbers. Then you turn on one number with one pattern (set of segments like 5, 6, or 3). Then you turn off the number. Then you turn on the next number with a different pattern. And so on. Let’s look at the code for CCC, DEV, SQD.

int time = 0;
int count;
void setup() {
//SEGMENTS
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(0, OUTPUT);
//SEGMENT CONTROL
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(A3, OUTPUT);
  pinMode(A4, OUTPUT);

}
void loop(){
  time = 3;

//ccc
if (count<100){
  digitalWrite (A1,HIGH);
digitalWrite (0, HIGH);
digitalWrite (1, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
delay(time);
digitalWrite (0, LOW);
digitalWrite (1, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (A1,LOW);

digitalWrite (A2,HIGH);
digitalWrite (0, HIGH);
digitalWrite (1, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
delay(time);
digitalWrite (0, LOW);
digitalWrite (1, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (A2,LOW);

digitalWrite (A3,HIGH);
digitalWrite (0, HIGH);
digitalWrite (1, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
delay(time);
digitalWrite (0, LOW);
digitalWrite (1, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (A3,LOW);

digitalWrite (A4,HIGH);
delay(time);
digitalWrite (A4,LOW);

}
if (count>100){
  if (count>200){
    goto a;
  }
  //letter D
digitalWrite (A1,HIGH);
digitalWrite (0, HIGH);
digitalWrite (1, HIGH);
digitalWrite (2, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
delay(time);
digitalWrite (0, LOW);
digitalWrite (1, LOW);
digitalWrite (2, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (6, LOW);
digitalWrite (A1,LOW);

  //letter E
digitalWrite (A2,HIGH);
digitalWrite (0, HIGH);
digitalWrite (1, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
digitalWrite (7, HIGH);
delay(time);
digitalWrite (0, LOW);
digitalWrite (1, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (7, LOW);
digitalWrite (A2,LOW);
 //letter V
 digitalWrite (A3,HIGH);
digitalWrite (1, HIGH);
digitalWrite (2, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
delay(time);
digitalWrite (1, LOW);
digitalWrite (2, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (6, LOW);
digitalWrite (A3,LOW);
}
a:
if (count>200){
  //letter S
digitalWrite (A1,HIGH);
digitalWrite (0, HIGH);
digitalWrite (1, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
digitalWrite (7,HIGH);
delay(time);
digitalWrite (0, LOW);
digitalWrite (1, LOW);
digitalWrite (4, LOW);
digitalWrite (6, LOW);
digitalWrite (7,LOW);
digitalWrite (A1,LOW);
  //letter Q
 digitalWrite (A2,HIGH);
digitalWrite (0, HIGH);
digitalWrite (1, HIGH);
digitalWrite (2, HIGH);
digitalWrite (6, HIGH);
digitalWrite (7,HIGH);
delay(time);
digitalWrite (0, LOW);
digitalWrite (1, LOW);
digitalWrite (2, LOW);
digitalWrite (6, LOW);
digitalWrite (7,LOW);
digitalWrite (A2,LOW); 


//letter D
digitalWrite (A3,HIGH);
digitalWrite (0, HIGH);
digitalWrite (1, HIGH);
digitalWrite (2, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
digitalWrite (6, HIGH);
delay(time);
digitalWrite (0, LOW);
digitalWrite (1, LOW);
digitalWrite (2, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (6, LOW);
digitalWrite (A3,LOW);
}
if (count>300){
count = 0;
}
count++;
}

In this case I am using analog pins A1, A2, A3 and A4 to do the transistor switching. I am using digital pins 0 to 7 to power the segments. It’s very long and tedious. That’s because the arduino has to turn on and off each part of the number matrix individually. I’m working on a shorter more algorithmic version and help would be appreciated from someone who’s done this before. Maybe there’ll be someone at MHV.Then again, it does only weigh in at around 2,000 bytes. But it’s unwieldy.

Anyway, you can see that I have achieved the illusion of lighting up different number combinations by turning on and off parts of the display (using the transistors as switches) really fast. Almost 16.000 MHZ fast. Now I know that doesn’t sound very fast compared to modern computers but it’s more than enough for this. That’s one of the cool things about the arduino. Less is more. Now I’m going to try and write something cleaner and more powerful. But at least I’ve achieved my initial goal. I’ll also do up a fritzing diagram at some point. I know all that sounded pretty confusing so if you don’t understand please leave a comment and I’ll get right back to you.

The synth prototype

After much stuffing around last week I can now tell you that I have built a fully functioning tape player synth prototype.It took about half an hour to build. And it sounds awesome. Really awesome. I’ll upload a proper hacker/maker style video of this working in the next week. I call it a prototype because it has an etherten board for brains which I plan to use for other things and it messy and extremely dodgy.

The back.

So the back has a speaker if you don’t have a big one to plug it into or can’t be bothered lugging one around and two wires for hooking it up to big speakers. There is a usb cable for power and programming.

The guts of the project.

Inside there is a rats nest of wires along with an arduino clone board. The original potentiometers are connected to the etherten’s power, ground and analog inputs. Here’s the extremely small amount of code that powers this project:

int note = 100;
int beat = 50;
int length = 10;
int pin = 9;

void setup() {
  pinMode(pin, OUTPUT);
}

void loop() {
  note= analogRead(0);
  length= analogRead(1);
  beat= analogRead(2);
  tone (pin,note);
  delay(length);
  noTone (pin);
  delay(beat);
   }

Analog pin 0,1 and 2 are hooked up to the potentiometers and read the changing voltages which is then output as sound. This makes the synth sound like not much fun to use but I can assure you it is. The atmega328 chip sometimes stuffs up the readings with interesting blips popping up every now and again. Certain combinations of voltages bring out these blips in full force providing a kind of random tone generator. There are a lot more imperfections allowing for weird sounds to be made using the synth. This is probably the most fun thing to use I have built with electronics. I promise I will upload a video in due course (probably some time this week) as it is a bit hard to convey sound with words and images. This thing is so much fun to use.

Measuring Electromagnetic Radiation with the Arduino

My mum is always going on about how mobile phones can damage your brain after reading online articles about it. So I decided to see what she was on about by building my own simple electromagnetic radiation detector to test what phones put out.

Phone radiation meter

Phone radiation meter

EM

Let’s start off by figuring out what it is we are trying to measure. Electromagnetic radiation is emitted by any piece of wire or metal passing current. Or that’s at least how my electronics teacher explained it to me. So when a phone calls up the telephone tower it has a lot of wires passing a decent amount of current through them, generating a fair bit of EM radiation.

The Huawei X1

I’ll be using my own huawei x1 as the test phone for this. I made this demo video of it below.

The circuit

The circuit is pretty simple for this project consisting of a piezo buzzer and a lot of wire. The circuit goes like this:

Circuit image developed using fritzing

Circuit image developed using fritzing

Circuit image developed using fritzing

OK so I did make one mistake in drawing these up (and in the picture at the top). The wire array should not be connected to 5V. The electromagnetic fields provide the power which pin A0 then reads.

Code

So once all that’s hooked up we can have a look at our code.

This is what it looks like. It’s basically a simple modification of the AnalogReadSerial sketch. All I did was make a modification so I could hear the changes in the magnetic fields.

/*
  AnalogReadSerial
 Reads an analog input on pin 0, prints the result to the serial monitor 
 
 This example code is in the public domain.
 */

void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue, DEC);
  tone(9, sensorValue);
}

Basically it reads how much current is being passed by the wire and prints that out to serial and as a tone on the piezo. Simple.

So we can log this data into our serial monitor. If you open the serial monitor with this sketch on your arduino then you should get a stream of data like this:

The serial feed

The serial feed

I recommend that you have the arduino feed data for about 10 seconds then unplug the arduino board. During these 10 seconds try waving your phone around and turning it on and off near the array to get results. You should hear the difference with the piezo making even uglier noises. Once the serial feed has stopped after you have unplugged the board copy and paste the data into excel. Select the data and make a line graph. You should get something like this. It looks pretty cool.

That's electromagnetic radiation emitted by my phone. That's pretty cool.

That's electromagnetic radiation emitted by my phone.

For the example of data above I was waving my phone around the array and accessing internet and stuff. The big spike is when I make a request to a 3G tower.

You can pretty much do this with any electronic device so experiment a bit. You can even make music that’s triggered by swiping your phone’s screen. With my Huawei X1, swiping the screen results in a spike in electromagnetic activity. This is a very primitive way to interface an android phone with an arduino. Who needs an ADK?

Actually figuring out how much energy is coming out of the phone will probably involve a lot of maths. I’m not terribly good at maths so I might leave to someone else to make another day.

So that’s how I measured how much radiation my phone puts out when it does various tasks. All you need is some wire and an arduino. It’s a good project to show how easily the arduino can be used for research. I’m still waiting to get my birthday pressies and I’ve got my fingers crossed that there might be some electronics money in there 🙂

 

 

I like numbers

Ethernet

A kid that I teach robotics to has begged me to show him some code examples of using an Etherten seeing as he just bought one. I’m not going to copy and paste more long and tedious code examples into my blog so I’m just going to give him some links.

The library and shield home:

http://www.arduino.cc/en/Reference/Ethernet

Lots of examples of ethernet and other comms.

http://arduino.cc/playground/Main/InterfacingWithHardware#Communication

The best example in my opinion (hint: this doesn’t work if you don’t type in the etherten’s IP address into the sketch (i.e. 1.2.45.6.10 blah blah blah). Don’t change the mac address.)

http://arduino.cc/playground/Code/WebServer

And don’t forget to read the instruction manual. I never read instruction manuals but you NEED to read this.

http://www.practicalarduino.com/freetronics/EtherTen_Getting_Started.pdf

And look at this amazingly cool project with arduino and ethernet. It should help you get started. It uses the same wiznet ethernet chip as  the etherten.

http://www.youtube.com/user/mrichardson23#p/c/3C4936C5BA46679D/18/DnFZsPlaknQ

There’s also a bit on this blog about ethertens and stuff.

That should get you started. 🙂

Display

Moving onto our main topic I’ve finally had a chance to test the server’s circuit. The main component of this is the display.

Display

The numeric display deeply nested inside the project

To test this I used the serial debugging program that I use to debug most things. You can find it in the category of Arduino Sketches.

So I set analog pins 1-4 high and digital pins 0-7 high and it all lit up.

Display lit up

All lit up.

Now the picture above may look at first like one for happiness and joy but I can assure you it’s not. The top and top left segments of the display are trouble. This is because they are hooked up to pins 0 and 1. Now pins 0 and 1 on the arduino do the TX and RX for the serial functions. This is bad. It means that these pins are inaccessible when using the computer with the board. I need to figure out a way around this.

So I tried having the arduino kind of  do a permanent Serial.print() command to keep the top segment (TX pin) bright. It worked. But what about the RX pin?

Time to build an ethernet debugger.

Nah I’m not that good.

Time to move away from the serial debugger and to a proper sketch.

I simply made a sketch that looked like this:

void setup() {
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(0, OUTPUT);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(A3, OUTPUT);
  pinMode(A4, OUTPUT);
  pinMode(A5, OUTPUT);

}
void loop(){
 digitalWrite(A1, HIGH);
 digitalWrite(A2, HIGH);
 digitalWrite(A3, HIGH);
 digitalWrite(A4, HIGH);
 digitalWrite(0, HIGH);
 digitalWrite(1, HIGH);
}

And the pins lit up like this:

TX and RX pin lit up

Problem solved

I tested the tilt switch using the good old AnalogReadSerial sketch. It worked. Server security? Check.

I know the piezo worked because it made several loud noises when I accidentally turned it on a couple of times in the library while debugging. Annoying noises that can be turned on remotely? Check.

Last but definitely not least the LM35 temperature sensor worked when I tested it with a LadyAda sketch. My room is a t 19.1 degrees celsius.

See http://www.ladyada.net/learn/sensors/tmp36.html for the code

So that’s about it for circuit testing.

Boards

As promised here are some more cool boards that are on my wishlist. Not as much detail this time around because I am in a hurry. Just click on the images to find out more.

Chumby

Chumby hacker board

Panda board. This thing is awesome. Ethernet and HDMI.

Panda board. This thing is awesome. Ethernet and HDMI.

The Digilent Cerebot 32MX7. Ethernet and a PIC32.

The Digilent Cerebot 32MX7. Ethernet and a PIC32.

Mbed dev board. Boasts an ARM and Ethernet at Arduino Nano size.

Mbed dev board. Boasts an ARM and Ethernet at Arduino Nano size.

So that’s about all the boards I can think of at the moment that are worth mentioning. I’ll have to find some more for you guys.

Sharks and Sticky Tape

Okay so to get started with I had to rewire the ethereten to the breadboard because I had to disconnect it when the etherten failed. I realized that I’ll probably use my etherten a lot even after I finish this server so I used some sticky tape to secure the pins in place in order. This means I can unplug the board easily.

Sticky tape

The slightly more secure wiring

The second cool thing that I want to show you before we delve into the server’s code is this awesome old shark pen that I found in my room. It’s got an awesome LED that lights up all different colors automatically.

Here’s a short demonstration showing what I mean:

shark light

A very cool pen

So that basically solves the problem of making my server look awesome at night. And the best thing is that it doesn’t need any PWM or any other fancy stuff because it has it’s own internal chip and acts just like a normal LED in circuit so I can just plug it straight into digital pin 8.

Code

Set it up

Let’s start with the arduino configuration (setup) code:

void setup(){

  /*Analog pin configurations*/
pinMode(A0, INPUT); //TILT SENSOR

/* LED number display control*/
pinMode(A1, OUTPUT);//DIGIT CONTROL
pinMode(A2, OUTPUT);//DIGIT CONTROL
pinMode(A3, OUTPUT);//DIGIT CONTROL
pinMode(A4, OUTPUT);//DIGIT CONTROL
pinMode(A5, INPUT);//DIGIT CONTROL

  /*Digital pin configurations*/  
pinMode(1, OUTPUT);//SEGMENTS
pinMode(2, OUTPUT);//SEGMENTS
pinMode(3, OUTPUT);//SEGMENTS
pinMode(4, OUTPUT);//SEGMENTS
pinMode(5, OUTPUT);//SEGMENTS
pinMode(6, OUTPUT);//SEGMENTS
pinMode(7, OUTPUT);//SEGMENTS

/*Digital pin 8 is not in use at the moment being left spare 
so it can serve as an ethernet
host for other arduino devices in my room. 
Or to turn on and off the cool LED that I found in an old pen.*/
pinMode(9, OUTPUT);//PIEZO
pinMode(8,OUTPUT); //awesome shark pen.
}

So that stuff basically tells the chip what each pin on the chip is going to do. I also added what is connected to each chip for easy reference when writing the code.

HTML

This part was pretty easy to do as I have experience in web development. Here’s what the output of the server looks like:

Screenshot of the server

Screenshot of the server's HTML output

As you can see I went for a very “hacker” kind of look because the thing is 8 bit and primitive. I’m not going to claim I can play flash games on an arduino like this guy: http://www.instructables.com/id/Arduino-Flash-game-streamer/

I mean all he did was use iframe HTML tags. Meh.

And here’s the code that powers the server output:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ardu Server</title>
	<style type=text/css>
	body{
		font-family: Courier;
		color: green;
		background-color: black;
		font-size: 30px;
	}
		h1{
		font-family: Courier;
		color: green;
		background-color: black;
		font-size: 60px;
	}
	</style>
</head>
	<body>
		<h1>Welcome to ardu serve v1.0</h1>
		<p>Server has not been stolen recently</p>
		<p>Lighting is on</p>
		<p>Temp = 36.15 degrees celsius</p>

	</body>
</html>

But to simplify things when we are putting our HTML into our arduino code I deleted all the indents. There’s not much point repeating that here.

I tried to unindent my code and it didn’t quite work as planned. Don’t just try cramming the webpage into on a line because the Arduino IDE only allows certain number of characters in a line before it cuts them off. I’m not about to write client.println() for every line in my HTML. So I guess I might have to go and do it like this guy.

// HTTP Request message
PROGMEM prog_char content_404[] = "HTTP/1.1 404 Not Found\nServer: arduino\nContent-Type: text/html\n\n<html><head><title>You Fail</title></head><body><h1>Looks like Lochie Ferrier has failed in his duty to maintain the arduserver</h1></body>";
PGM_P page_404[] PROGMEM = { content_404 }; // table with 404 page

// HTML Header for pages
PROGMEM prog_char content_main_header[] = "HTTP/1.0 200 OK\nServer: arduino\nCache-Control: no-store, no-cache, must-revalidate\nPragma: no-cache\nConnection: close\nContent-Type: text/html\n";
PROGMEM prog_char content_main_top[] = "<html><head><title>Arduino Web Server</title><style type=\"text/css\">table{border-collapse:collapse;}td{padding:0.25em 0.5em;border:0.5em solid #C8C8C8;}</style></head><body><h1>Lochie Ferrier's arduserver</h1>";
PROGMEM prog_char content_main_menu[] = "<table width=\"500\"><tr><td align=\"center\"><a href=\"/\">Home</a></td><td align=\"center\"><a href=\"page2\">Page 2</a></td><td align=\"center\"><a href=\"page3\">Page 3</a></td><td align=\"center\"><a href=\"page4\">Page 4</a></td></tr></table>";
PROGMEM prog_char content_main_footer[] = "http://www.lochieferrier.com</body></html>";
PGM_P contents_main[] PROGMEM = { content_main_header, content_main_top, content_main_menu, content_main_footer }; // table with 404 page
#define CONT_HEADER 0
#define CONT_TOP 1
#define CONT_MENU 2
#define CONT_FOOTER 3

// Page 1
PROGMEM prog_char http_uri1[] = "/";
PROGMEM prog_char content_title1[] = "<h2>Page 1</h2>";
PROGMEM prog_char content_page1[] = "<hr /><h3>Content of Page 1</h3><p>Nothing... yet.</p><br /><input type=\"text\" name=\"prova\">";

Basically he stores the webpages as part of the chip’s program memory. He has a five page system that even has get and post functions. When it gets a request it does some freaky deaky stuff that I don’t understand and gets the requested webpage along with a template (headers etc) and spits it out to the user. This was the original server infrastructure that I was going with but I wanted to try and build my own but now I think I’m just going to try and extend his masterpiece. Here’s the full version:

http://www.arduino.cc/playground/Code/WebServer

That guy is a god.

And I’ve still got to test that the circuit is even working……

Chips

Okay so seeing as I gave away my ebay arduino to my electronics teacher and my etherten is kind of going to be occupied I’ve started looking around for some new silicon.

Here’s the first cool one:

Chipkit uno32

Chipkit uno32

PIC32 board that's compatible with all things Arduino. Enough said.

This handy little board costs the same as a regular arduino, has a lot mor outputs and costs $32. That’s pretty good. But it’s worth mentioning that this board doesn’t run a full PIC32. It only runs a limited one that doesn’t have Ethernet, USB hosting or CAN. So you get 32bit and a lot of inputs but not much else. http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,893&Prod=CHIPKIT-UNO32

Specs:

  • Microchip® PIC32MX320F128 processor
    • 80 Mhz 32-bit MIPS
    • 128K Flash, 16K SRAM
  • Compatible with existing Arduino™ code examples, reference materials and other resources
  • Can also be programmed using Microchip’s MPLAB® IDE (along with a PICkit 3 and our PICkit3 Programming Cable Kit, seen below)
  • Arduino™ “Uno” form factor
  • Compatible with Arduino™ shields
  • 42 available I/O
  • User LED
  • Connects to a PC using a USB A -> mini B cable (not included)

The good news is that this thing has a big brother that is predictably named the Chipkit max32

Chipkit max32

Chipkit max32

This one has ethernet and a lot of outputs.

How is this one worth $20 more? It has ethernet and USB hosting and everything else you need. And Arduino compatibility. This thing could run a disco with ease. I want one. http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,894&Prod=CHIPKIT-MAX32

Specs:

  • Microchip® PIC32MX795F512 processor
    • 80 Mhz 32-bit MIPS
    • 512K Flash, 128K RAM
    • USB 2.0 OTG controller
    • 10/100 Ethernet MAC
    • Dual CAN controllers
  • Provides additional memory and advanced communications peripherals
  • Compatible with existing Arduino code examples, reference materials and other resources
  • Can also be programmed using Microchip’s MPLAB® IDE (along with a PICkit 3 and our PICkit3 Programming Cable Kit, seen below)
  • Arduino™ “Mega” form factor
  • Compatible with Arduino™ shields
  • 83 available I/O
  • User LED
  • Connects to a PC using a USB A -> mini B cable (not included)

So those are the digilent pic32 boards.

I’ll show you some more tomorrow that I have been pondering over like the mbed, cool ebay boards, chumby, beagle and the Cerebot 32MX7.

 

I haven’t really had time to check all this over because I did all this in half an hour so don’t kill me for spelling or factual errors.