Category Archives: software

Simple Arduino Robot Control

One of the simplest bits of functionality that is useful for small-scale robotics is the ability to control robots over the serial port, which can easily be made wireless using Pololu Wixels, XBee, bluetooth, or any other wireless serial connection. Since the Arduino Serial Monitor only sends out messages rather slowly, and it’s usually nice to have a fast response from computer to robot, I wrote a short Java application that handles the communication for you.

Download here:

Robot Controller
Source code is released into the public domain, but if you use it, I’d appreciate it if you cite me somewhere (Robert Ying).

You’ll also need to have the appropriate rxtx native library in the same folder as the jar file when running it—you can download that here

Corresponding Arduino Code:

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

// method that sets motor speeds from -255 to 255
// corresponding to full reverse and full forward
void setLeftMotor(int speed);
void setRightMotor(int speed);

byte nextByte() {
  unsigned long start = millis();
  while (millis() - start < 100) {
    if (Serial.available()) {
      return Serial.read();
    }
  }
  return 0x00;
]

void loop() {
  while (Serial.available()) {
    switch(Serial.read()) {
      case 0xC1: setLeftMotor(2 * nextByte()); break;
      case 0xC2: setLeftMotor(-2 * nextByte()); break;
      case 0xC5: setRightMotor(2 * nextByte()); break;
      case 0xC6: setRightMotor(-2 * nextByte()); break;
      default: setLeftMotor(0); setRightMotor(0); break;
    }
  }
}
Read More Leave a Comment

November 30, 2011

Categories:

Robotics, software

Arduino Quine

One of the things programmers tend to learn how to do in every language they know is how to write a quine – that is, a program that echoes its own source code out to the user, without reading the source code directly. This is an inherently recursive operation, so language-based tricks are needed to get it to work.

The Arduino is programmed in C++, however, there is no std::cout. Instead, user input is usually through the USART on the Arduino, and as such needs to initialize and print out from that port.

Traditionally, C/C++ quines are written using the preprocessor and the printf command, as it allows for simple replacement of strings with characters, thereby overcoming the recursive operation. As such, I use the sprintf command below (Arduino’s HardwareSerial doesn’t support formatted prints, sadly enough).

Read More Leave a Comment

May 21, 2011

Categories:

software

FlexLab

I’m playing with the FlexLab right now… it could use a decent amount of improvement. It appears to be some version of a reshelled VNC client-server paradigm. It has the same, annoying lag – maybe 100ms, minimum. Seems totally overrated – horrible interface and latency problems. It also doesn’t have any resolution to speak of: 800x600px – I don’t know what they’re doing.

Read More Leave a Comment

September 3, 2010

Categories:

School, software

robo.hack

The game robo.hack is the result of the last month’s worth of coding by myself, Karthik Viswanthan, and Virup Gubba. It is based on nethack, and should be relatively easy to learn.

System Requirements

The following are required for installation:

  • Java Runtime Environment Version 1.60+
  • Minimum of 2 MB space for game itself and about 100 MB including JDK
  • Preferred 200 MB

Installation Instructions

Robo.hack can be run by clicking on the executable jar file with the aforementioned system requirements.

How to Play

Robo.hack’s controls are completely outlined on the title screen. Use the arrow keys to move and the q, w, e, a, s, d, z, and c to attack (eight different directions means eight keys, centered at s). The inventory and player status can be toggled using the ‘i’ and ‘p’ keys respectively. Once toggled, the up/down arrow buttons should be pressed to target the correct item or skill. Subsequently, hit enter to either add a skill point or use an item. To untoggle, use the escape or delete key, or press the enable key again.

Following the title screen, the player will be prompted for a profession. Pick the one of your choice by hitting the respective key.

Now just explore throughout the world and try to beat all the levels. Monsters will attack you on the way. They will drop various items and weapons for you to use on your journey. As you continue to fight, you’ll gain experience and skill points, which you can use to power up your abilities. Think wisely. Play wisely. Good luck!

Hopefully you won’t see this screen on your journey.

You can download the game here:
robo.hack.zip

robo.hack is released under the GPL v3, source available soon!

Leave any questions and/or comments below.

Read More Leave a Comment

June 4, 2010

Categories:

software

PHP Obfuscation

obfuscated code

Read More Leave a Comment

February 10, 2010

Categories:

software

 
Content-Type: text/html