Category Archives: Projects

Complete electronics and embedded projects

Getting hands on Arduino Ethernet Shield

 

Updated! Arduino Ethernet code

Since last Arduino Ethernet code there we several Arduino IDE releases with changes that affected the code listed in this post. Due high interest, we updated it with minor changes that makes it work as expected. The biggest occurred because Wstring.h library isn’t no longer in use, because String.h library is included in core that brings some difference in several functions used in code.

In code we need to write

readString += c; instead readString.append(c);

if(readString.indexOf(“L=1″) >0) instead if(readString.contains(“L=1″))

Also we need to re-import Ethernet.h library in order to bring along all necessary libraries like Client.h, Server.h, SPI.h, Udp.h.

The other problem occurred when program run was that LED actually never lights up when checkbox is selected. I used Serial.print(c); to track down the problem. And it seems that method GET sends two strings:

Our code was catching and analyzing both strings. We only need to take string where parameter is sent: “GET /?L=1 HTTP/1.1” and skip “GET /favicon.ico HTTP/1.1”. As our example is very simple we can see ,that second string lacks “?” symbol. So we check the string if there is a ‘?’ symbol, of not, skip whole analyze.

And last fix is applied to LED checkbox. Now it stays checked if LED is ON. Hope you find these changes useful.

Here is a code listing:

#include <SPI.h>
#include <Client.h>
#include <Ethernet.h>
#include <Server.h>
#include <Udp.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 110 };			// ip in lan
byte gateway[] = { 192, 168, 0, 1 };			// internet access via router
byte subnet[] = { 255, 255, 255, 0 };                   //subnet mask
Server server(80);                                      //server port
byte sampledata=50;            //some sample data - outputs 2 (ascii = 50 DEC)
int ledPin = 4;  // LED pin
char link[]="http://www.scienceprog.com/"; //link data
String readString = String(30); //string for fetching data from address
boolean LEDON = false; //LED status flag
void setup(){
//start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
//Set pin 4 to output
  pinMode(ledPin, OUTPUT);
//enable serial datada print
  Serial.begin(9600);
}
void loop(){
// Create a client connection
Client client = server.available();
  if (client) {
    while (client.connected()) {
   if (client.available()) {
    char c = client.read();
     //read char by char HTTP request
    if (readString.length() < 100)
      {
        //store characters to string
        readString += c; //replaces readString.append(c);
      }
        //output chars to serial port
        Serial.print(c);
        //if HTTP request has ended
        if (c == '\n') {
          //dirty skip of "GET /favicon.ico HTTP/1.1"
          if (readString.indexOf("?") <0)
          {
            //skip everything
          }
          else
          //lets check if LED should be lighted
        if(readString.indexOf("L=1") >0)//replaces if(readString.contains("L=1"))
           {
             //led has to be turned ON
             digitalWrite(ledPin, HIGH);    // set the LED on
             LEDON = true;
           }else{
             //led has to be turned OFF
             digitalWrite(ledPin, LOW);    // set the LED OFF
             LEDON = false;
           }
          // now output HTML data starting with standart header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          //set background to yellow
          client.print("<body style=background-color:yellow>");
          //send first heading
          client.println("<font color='red'><h1>HTTP test routines</font></h1>");
          client.println("<hr />");
          client.println("<hr />");
          //output some sample data to browser
          client.println("<font color='blue' size='5'>Sample data: ");
          client.print(sampledata);//lets output some data
          client.println("<br />");//some space between lines
          client.println("<hr />");
          //drawing simple table
          client.println("<font color='green'>Simple table: ");
          client.println("<br />");
          client.println("<table border=1><tr><td>row 1, cell 1</td><td>row 1, cell 2</td></tr>");
          client.println("<tr><td>row 2, cell 1</td><td>row 2, cell 2</td></tr></table>");
          client.println("<br />");
          client.println("<hr />");
          //printing some link
          client.println("<font color='blue' size='5'>Link: ");
          client.print("<a href=");
          client.print(link);
          client.println(">Visit Scienceprog!</a>");
          client.println("<br />");
          client.println("<hr />");
          //controlling led via checkbox
          client.println("<h1>LED control</h1>");
          //address will look like http://192.168.1.110/?L=1 when submited
          if (LEDON)
          client.println("<form method=get name=LED><input type=checkbox name=L value=1 CHECKED>LED<br><input type=submit value=submit></form>");
          else
          client.println("<form method=get name=LED><input type=checkbox name=L value=1>LED<br><input type=submit value=submit></form>");
          client.println("<br />");
          //printing LED status
          client.print("<font size='5'>LED status: ");
          if (LEDON)
              client.println("<font color='green' size='5'>ON");
          else
              client.println("<font color='grey' size='5'>OFF");
          client.println("<hr />");
          client.println("<hr />");
          client.println("</body></html>");
          //clearing string for next read
          readString="";
          //stopping client
          client.stop();
            }
          }
        }
      }
 }

And you can download Arduino sketch ethtest.

Continue reading

New project batch from Cornell University ECE 4760

It’s been a regular tradition every spring to check out on what’s new in Cornell University ECE 4760 final microcontroller projects. This year isn’t an exception. It seems that they started a 2010 list on new great AVR ATmega644 projects.

List is still building up but there already is a 20 project list with projects like Human Tetris, Glove Midi Controller, Talking Voltmeter and other. All projects are compiled with WinAVR/GCC tools – so everyone can take a glance and give a try. It’s a great list of projects starting from 1999 so there are tons of great interfacing examples, code snippets and even ideas for your new project. Keep eye on that lists as there are more to come (it always reaches about 40). Way to go ECE 4760!

Sticky Light – The Art of Pure Light Interaction

People always say that it’s impossible to catch a light, as the light moving in a very high speed. However, if you’re giving the opportunity to grab and hold the laser light in your palms, would you mind to give it a shot?

Sticky Light on palms

As you can see on the above picture, a person is holding the red laser light inside his/her hands. Theoretically, it’s a laser spot bounces on a figure being drawn on paper and trying to escape the labyrinth of lines.

No camera or projector is used in the experiment. The Sticky Light proposes an experience and allows the users to touch and interact with a beam of pure light. It even fun, when you can play the classic PONG game with this Sticky Light all with your bare hands! Continue reading

The Connection of Open-source Camera with Digital Photography

Did you know that camera is regarded as one of the most ancient invention, which is having nearly thousand years of history?

According to the history, the idea of the very first camera had been recorded in a book called, “Book of Optics” in 1015 by the incredible Arabic scientist Ibn al Haytham (Alhazen). Believe it or not, Alhazen, which is also known as “Ptolemy the Second” was the first person who proved that light travels in straight lines. He recorded the theory in the Book of Optics as well! This book had important influence on the development of optics and that’s why Alhazen is also being known as the “Father of modern optics”.

Well, time marches on and we’ve already came to the 21st century, where the digital and optic cameras have been part of our life.

Marc Levoy, a professor from Stanford University, California has been trying to develop a new type of camera. He called his invention as “Frankencamera” (Hmm…, maybe it has something to do with Frankenstein?).

He described that the open-source digital camera is no longer be limited by the software, instead the programmers have the chance to build up new software to teach the open-source cameras some new tricks!

Well, Levoy’s ultimate plan is to invent and manufacture the “Frankencamera” as a platform with the cheapest cost as possible. He’s now co-operating with Andrew Adams, one of his students to make the Frankencamera becomes a reality! [stanford.edu]

MattsOffice – The Wonderful Home Automation via Twitter!

How long you’ve used the internet? Well, if you’re still a newbie, then you might never hear about Twitter before, but for those people who have been an internet users for couple of years, they are very familiar with the social networks, such as Facebook, Myspace and Twitter.

By the way, as one of the engineer who frequently surfs the internet, Matthew Morey, had invented the smart “MattsOffice”, which is a home automation via Twitter.

MattsOffice

Morey himself is a big fan of Twitter. He always wants to build a home automation via Twitter that allows him to have the connection through various types of household appliances, such as personal PC, iphone, GPS and much more.

According to Morey, there’s one thing that lacking in most of the devices, which is the 2-way communication between Twitter and the device. Normally, you’re able to send an update to Twitter, but are never performing an action based on a Twitter message!

However, Morey had found the solution, and applied it on the MattsOffice. He mentioned that the MattsOffice is a perfect device; which is possible for you to send a command by placing a keyword in a @reply message.

Let’s say if you want to know the temperature of your home office, you only need to update the Twitter status with some simple question like “@MattsOffice What is the current temperature”. Then, the answer will be outputted on your desktop LCD display with the possible answer (It might say, “hot or cold”).[matthewmorey.com]

The Powerful R/C Steam Turbine Tank

Are you having the guts to play with fire? Hmm…, if you don’t mind to look by other like a freak and would do anything to stand out from the crowd, then you might want to build this powerful R/C steam turbine tank.

This R/C steam turbine tank is a very instructable project made by crabfu. Actually, it built based on an R/C machine that is carrying flammable gas (That’s why we should watch out with it, as you’re playing with fire here). It able to produce extremely high steam pressure, which is capable of causing fire alarm to be responded on it!

RC Steam Turbine Tank

In order to handle this “hyper fire monster”, you must pay proper attention, or you’ll be suffered with blisters on your finger, or even get your house burnt down instantly! Continue reading

Twittjr – The Finest Combination of IBM PCjr and Twitter!

IBM, as one of the world’s largest computer company and system integrator, has been created many different types of computers. Amongst the IBM’s computers, the IBM PCjr is considered the very first attempt of IBM corporate to enter the market for relatively inexpensive educational and home-use personal computers.

The IBM PCjr introduced in 1984 and it has a 4.77MHz processor, 128KB of RAM and 360KB floppy disks for storage. If we compared these features to the recently computers, it’s totally outdated!

Well, instead of keep putting the unused IBM PCjr in the storeroom, isn’t it better to modify it a little bit and turn it into Twittjr?

Did you know that Twittjr is a marvelous system that allows an old IBM PCjr to search the public timeline on Twitter? Ok, you’re wondering, “How the Twittjr works?”

Well, let’s say you have a IBm PCjr. First of all, you must hook it to an internet-connected computer. The PCjr is used to call the server and establishes a modem connection, which it uses to send a request for whatever search term the user have entered into the computer. Then, the server uses the Twitter Search API to download the three most recent posts on the public timeline and displays them on the screen! [grantovich.net]

New series of AVR projects from Cornell

It’s been a tradition to check on new projects from Cornell University ECE 4760 Engineering class. They build cool AVR based projects each year and seems that they are getting more and more advanced. During the last 5 weeks of the semester in ECE 4760, Microcontroller Design, students had to combine sensors, actuators, microcontrollers, and mathematical techniques to build something. So 2009 final end up with whole 39 cool projects that include a 3D mouse, Haptic appointment manager, fart detector, tissue impedance biopsy system and several interesting musical instruments. This year the coding was done using WINAVR GCC and AVRstudio.

You can hardly find so many AVR projects in other place that are well researched and described. And this number is growing since 1999.

This is a great idea to publish these projects instead of stacking them somewhere in dark place like many universities do. Students do lots of interesting stuff why not sharing these ideas, so others could make things even better. Way to go ECE 4760 class. All projects show a great deal of originality and work. There are over 300 projects on the page.

Time for Launching Some Shooting War!

Working, working and working…What a long and boring working hours! If you’re too bored at the workplace, and you would like to have some fun here, then this cheap shooting range might be your perfect choice!

First of all, you don’t have to worry about the building cost for this project, as it is extremely cheap (It cost you about $35 or maybe cheaper). Furthermore, this project is so easy, as you can set up in less than an hour!

components-for-shooting-range

Some of the basic components that you need for the project are: Continue reading

The Latest Wiimote Virtual Reality Desktop

You’re feeling bored about the currently desktop? So, do you want to switch it into the latest Wiimote virtual reality desktop? Then, this is the right time for you to do now…

Do you believe that with two Nintendo Wii Remote (Wiimote), you can easily build up a virtual reality desktop? It might sound impossible, but the truth is you can really do it! Of course, instead of Wiimote, you still have to prepare the following components:

  1. IR-LEDs,

  2. Stripboards,

  3. Battery holder,

  4. Anaglyph 3D Glassed (Either in Red or Green Glasses),

  5. Compatible PC Bluetooth adapter, and

  6. Stack.

The term “Virtual Reality (VR)” has been around for many years, but is still associated with the special and expensive hardware. The Virtual Reality is only familiar in the research laboratories and big technology companies.

For your information, the speaking Virtual Reality can be differential by two things:

Immersion

The user is normally getting the impression of being inside a computer-generated world. Virtual Reality systems use the stereoscopic output devices to give the user a real 3D impression of the virtual world.

Interactivity

When the user is interacting with the virtual world, by navigation and manipulation of the objects, then the definition for Virtual Reality is complete.

By the way, this project will only cost you about $100 and you’ll get it done in less than 4 hours!

New on WinAVR Tutorial New on WinARM Tutorial