Introduction: Build a Pixel Nanobot

About: I'm an Emu. As a young chick my parents use to feed me watermelon and I loved it so much everyone nick named me, you guessed it, watermelon. Now that I have moved away from home I rarely get to eat any waterme…

Help prepare yourself for nanotechnology. In the near future you may be building very small robots to operate in microscopic, cellular and even molecular space.

If you have an old computer that will run Quick Basic or one that is newer which will run a more advanced language like Visual Basic then before spending money on parts you can explore the realm of robots by building a pixel nanobot.

I was surprised at all of the things I could do with a pixel nanobot on screen without having to commit money to motors and gears. In fact by building pixel nanobot first I was able to save a lot of time and money when I built my real world robot by exploring the difference between autonomic and cognitive jobs. Besides, if you can't control a pixel nanobot on your own computer screen then why bother trying to control a robot in the real world?

The pixel nanobot serves as the center for both sensors and actuators capable of assessing conditions and executing actions the same as its hardware counterpart.

Although a single pixel can do lots of interesting things if one pixel is not enough you can another nanobot or even create a nanobot swam to handle one or more tasks which are more demanding, like finding and eliminating a stealthy virus.

Step 1: Create the Pixel Nanobot(s)

Your screen, depending on its resolution, has thousand of pixels to work with. The pixel nanobot I built uses pixel color for identification and to keep track of where the nanobot has been.

I built my first pixel nanobot by setting all of the empty pixels to gray and then setting a obe pixel at a random location to one of 16 basic colors but using RGB code notation you can create more than 65,000 individual nanobots which can be uniquely identified.

Here is the code idea I used.

Set background color to gray
backcolor = &H8000000F&

Find a random location on the screen
x = rnd * scalewidth
y = rnd * scaleheight

Set the color of the pixel at that location to whatever color you want.
pset (x,y),QBcolor(0)

The next step is to give the nanobot a sensor.

Step 2: Give Your Pixel Robot Some Sensors

This is not hard at all, just look at the pixels surrounding your nanobot and see what color they are. If they are gray then they are empty.

The following code looks at the nanobot pixel and each pixel that surrounds it and is ready to give a status report using the variable "z".

for i = -1 to 1
for j = -1 to 1
a = x + i
b = y + j
z = point(a,b)
next j
next i

z will contain the color of the pixel "sensed"at the location of a and b. In fact, since your robot can sense the color of any pixel at any location you will eventually need to set up rules which justify long distance sensing, such as by using "radar" or one of the nanobot's designated probes.

The next step (no pun intended) is to give your nanobot some legs.

Step 3: Give Your Pixel Robot Some Legs

Legs are very uncomplicated for a nanobot although you can make them long and complicated with code.

Just set the pixel in the current location to the background color unless you want to leave a trail and set one of the pixels surrounding your nanobot to the same color of your nanobot in the direction you want to it go.

set(x,y) = backcolor

x = x + -1
y = y + 0

set(x,y), QBclor(0)

Step 4: Let Your Pixel Robot Go for a Walk

Pretend your robot is blindfolded or a bit undecided and send it out for a random walk.

a = rnd
b = rnd

If you want your nanobot to go in a general direction but still to take random steps you can add bias to the values of a an b such as by adding a minus one.

Step 5: Use Your Imagination

From here its just a mater of using your imagination to select the location of any pixel on the screen to see what color it is and to set it to the desired color or to explore a mired of conditions upon which to base whatever action is called for.

Here is some initial code that will bring you up to speed.

You can make the virus smaller or add obstacles and barriers and the code to overcome them and simulate any task you want.

The purpose of the Instructables is to encourage original research and for you to use your imagination, so give it all you can.

Have fun!

'NANOBOTS - a cluster of virus attack robots
'Declare variables.
Dim CX, CY, r(20) As Single, s(20) As Single
Dim i, j, a, b, c, d, e, f, g, h, k, l, m, n
Dim p(20), u, q(20) As Boolean, guts As Boolean
Private Sub Form_Load()
Dim Xpos, Ypos
With Form1

.Caption = "Robots"
.FillColor = vbBlue
.Top = 10
.Left = 10
.Height = Screen.Height * 0.75
.Width = Screen.Width * 0.75
.AutoRedraw = True
.DrawWidth = 1 ' Set DrawWidth.
.ScaleMode = 3

End With
Xpos = Form1.ScaleWidth / 2 ' Get horizontal center.
Ypos = Form1.ScaleHeight / 2
Timer1.Enabled = True
Timer1.Interval = 32767
'Get vertical center.
CX = Xpos * Rnd
CY = Ypos * Rnd
Form1.CurrentX = CX
Form1.CurrentY = CY
u = Point(CX, CY)
'---- objective virus ------------------------------------------------
Form1.Circle (CX, CY), 30, vbBlue
q(9) = True
guts = False
'---------- set bots starting point --------------------------------
For i = 0 To 15
r(i) = Rnd * ScaleWidth
s(i) = Rnd * ScaleHeight
a = 0
b = 0
'----- send nanobots to find and capture virus -----------
'==== send whole cluster =====================
For i = 1 To 15
If q(i) = True Then GoTo benzoid
'--------- compute target bias -------------------
c = Int(r(i)): d = Int(s(i))
g = Abs(c - a)
h = Abs(d - b)
o = 1
'----------- find blue or u --------------------
If o < 3 Then o = o + 1 Else GoTo benzoid
'-------- select next position at random ----------------
e = Int((o * Rnd) - (o - 1) * Rnd) ' + Int((2 * Rnd) - Rnd)
f = Int((o * Rnd) - (o - 1) * Rnd) ' + Int((2 * Rnd) - Rnd)
r(i) = c + e
s(i) = d + f
'-------- select next positon as closest to target -------------
If (Abs(r(i) - a) > g Or Abs(s(i) - b) > h) And a > 0 Then GoTo semper
If r(i) < 5 Then r(i) = r(i) + 1
If r(i) > Form1.ScaleWidth - 5 Then r(i) = r(i) - 1
If s(i) < 5 Then s(i) = s(i) + 1
If s(i) > Form1.ScaleHeight - 5 Then s(i) = s(i) - 1
Xpos = r(i): Ypos = s(i)
p(i) = Point(Xpos, Ypos)
If p(i) = vbBlue Then Exit Do
DoEvents ' Yield to other
Loop Until p(i) = u Or (r(i) = a And s(i) = b)
'======== when virus found ======================
If p(i) = vbBlue And a = 0 Then
'set a and b to target location
a = Int(r(i))
b = Int(s(i))
guts = True
End If
'PSet (r(i), s(i)), QBColor(i)
Line (c, d)-(r(i), s(i)), QBColor(i)
Next i
Loop ' processing.
End Sub

Have fun!