Etch-A-Netduino Go - Creating an Etch A Sketch with the .Net Micro Framework and the Netduino Go

The final project in our Diagramming week is a stretch. Yet it's a "diagramming/drawing" project that might of been our first introduction to it. This project takes a fun toy we played with (cough... or still play with... cough...) and brings it into our hardware building, Netduino lives...

Etching sketches with a Netduino Go

image

Netduino Go is designed for much more than toy projects, but one has to recognize that toy projects are fun and also great learning experiences. Today, I want to take you through the process of reproducing the behavior of a famous toy that you will surely recognize. That toy, that has helped many of us realize what poor motor skills we possess, has two knobs that control the horizontal and vertical coordinates of a pen that draws into the dust on the back of a simple screen. It’s a great mechanical device that is part of western culture.

Our version will use two potentiometers, a 320x240 LCD display, a button to erase the screen, and of course a Netduino Go. The hardware setup looks like the following:

image

We connected the button to port 2 (but it doesn’t matter as there’s only one), the two potentiometers to ports 3 and 4, and the display to port 5.

We can initialize this setup with the following code:

private Potentiometer Vertical = new Potentiometer(GoSockets.Socket3);
private Potentiometer Horizontal = new Potentiometer(GoSockets.Socket4);
private Button Button = new Button();
private VirtualCanvas Canvas = new VirtualCanvas();

To initialize the display, I wrote this method, which initializes a VirtualCanvas object on socket 5, sets the orientation of the display to landscape, fills the screen with white and flushes the command buffer:

public void InitCanvas() {
Canvas.Initialize(GoSockets.Socket5);
Canvas.SetOrientation(Orientation.Landscape);
Canvas.DrawFill(white);
Canvas.Execute();
}

The VirtualCanvas object can be seen as the driver for the display. It’s a simple vector API, but a crucial point is that these vector drawing primitives are not executed on the Netduino. Instead, they are serialized, sent to the display and executed there. This keeps communication between the microcontroller and the screen to a minimum, and frees the Netduino main board computing power. Essentially, you have a graphics coprocessor bundled with that screen. This is also why you need to call Execute when you want a command batch to be sent to the display and drawn.

To do the actual drawing, all we need is to read the values from both potentiometers and convert them into screen coordinates:

Here's a snap of the Project (which you can get by clicking through and going to the bottom of the post);

SNAGHTML138e2a12

Note: This project uses the .Net Micro Framework 4.2, which you can get here, .NET MF 4.2 (RTM) - SDK 4.2 (RTM) and the Netduino Go Netduino SDK v4.2.0

If you'd like to learn a little more about the Netduino Go, make sure check out this post, Electronics for developers with Netduino Go

Wouldn’t it be great if you could build your own stuff? Microcontrollers let you do that, but they usually require dealing with a lot of complexity and unknowns. If you’re a software developer, chances are you don’t really know how to use a capacitor, or how a transistor works, even though it is at the heart of all computers.

Well there is a way now to develop awesome hardware projects without knowledge of electronics, just by connecting modules together. Netduino Go is a platform that allows for that without constraining the types of projects you can build. Today the number of available modules is still limited (the platform was released only this month), but it is expected to grow fast.

In this post, I’ll introduce you to the platform, with the assumption that you know programming but not electronics.

So let’s get started. What you need to follow along this post is the following:

First we’ll create a new project, selecting the Netduino Go Application project type:

...

Tags:

Follow the Discussion

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.