Hands-On: Flying Drones With Scratch

I’ll admit it. I have a lot of drones. Sitting at my desk I can count no fewer than ten in various states of flight readiness. There are probably another half dozen in the garage. Some of them cost almost nothing. Some cost the better part of a thousand bucks. But I recently bought a drone for $100 that is both technically interesting and has great potential for motivating kids to learn about programming. The Tello is a small drone from a company you’ve never heard of (Ryze Tech), but it has DJI flight technology onboard and you can program it via an API. What’s more exciting for someone learning to program than using it to fly a quadcopter?

For $100, the Tello drone is a great little flyer. I’d go as far as saying it is the best $100 drone I’ve ever seen. Normally I don’t suggest getting a drone with no GPS since the price on those has come down. But the Tello optical sensor does a great job of keeping the craft stable as long as there is enough light for it to see. In addition, the optical sensor works indoors unlike GPS.

But if that was all there was to it, it probably wouldn’t warrant a Hackaday post. What piqued my interest was that you can program the thing using a PC. In particular, they use Scratch — the language built at MIT for young students. However, the API is usable from other languages with some work.

Information about the programming environment is rather sparse, so I dug in to find out how it all worked.

Continue reading “Hands-On: Flying Drones With Scratch”

Flash And Debug ESP8266 Boards On Android

Have an ESP8266 development board such as the NodeMCU or Wemos D1? You’re currently reading Hackaday, so probably. Got an Android device kicking around? Also seems fairly likely. In that case, you should check out ESP8266 Loader by [Bluino Electronics]. This recently released application lets you not only flash new binaries to any ESP8266 board using the FTDI, PL2303, CH34X and CP210X USB chipsets, but also offers a serial monitor for debugging on the go.

You’ll need a USB OTG cable to get your ESP board jacked in to your Android device, but you don’t need root or even to fiddle with the development settings. Here at the Hackaday R&D Dungeon we had somewhat mixed success getting a random selection of Android devices to work fully; all of the ones tried could at least open the serial monitor and read what a pre-programmed ESP was saying, but not all of them could successfully program a board.

Even on the devices where programming worked, it was slow. Just a basic LED blinking Sketch took long enough to write to our test Wemos D1 Mini that we contemplated getting a snack. But still, it shows a lot of promise for managing devices in the field, especially if you don’t have over the air update enabled in your code.

We especially liked that ESP8266 Loader helpfully downloaded a bunch of example binaries, many of which could be of practical use. There are programs for toggling the different GPIO pins on the board, creating Wi-Fi access points, and even a basic web server. With these in hand, you could actually do some testing and diagnostic work right from your mobile device.

This isn’t the first time we’ve seen an ESP8266 team up with a mobile device, but generally speaking, the magic is done over WiFi or Bluetooth.

Algorithms For Visual Learners

Computer programming is a lot like chess. It is fairly simple to teach people the moves. But knowing how the pieces move isn’t the reason you can win. You have to understand how the pieces work together. It is easy to learn the mechanics of a for loop or a Java interface. But what makes programs work are algorithms. There are many books and classes dedicated to algorithms, but if you are a visual learner, you might be interested in a site that shows visualizations of algorithms called VisuAlgo.

The site is from [Dr. Steven Halim] and is meant for students at the National University of Singapore, but it is available “free of charge for Computer Science community on earth.” We suspect if any astronauts or cosmonauts wanted to use it in space, they’d be OK with that, too.

The animations and commentary take you through algorithms ranging from the common — sorting and linked lists — to the obscure — Steiner and Fenwick trees. Each animation frame has some commentary, so it isn’t just pretty pictures. The site is available in many languages, too.

Many of the animations allow you to set up problems and execute them using a C-like pseudo language. When it executes, you can watch the execution pointer and a box comments on the current operation. For example, in the linked list unit, you can create a random doubly linked list and then search it for a particular value. Not only can you see the code, but the graphical representation of the list will update as the code runs.

The site allows you to register for free to get additional features, but we didn’t and it was still a great read about many different data structures. Also, a few of the commentary slides require you to show you are actually a computer science professor — we assume there’s some copyright issue involved because it is only a few.

This site is a great example of how many free educational resources are out there on the web. It isn’t just computer science either. MITx — or more generally, edX — has some great hardware classes and many other topics

Directly Executing Chunks Of Memory: Function Pointers In C

In the first part of this series, we covered the basics of pointers in C, and went on to more complex arrangements and pointer arithmetic in the second part. Both times, we focused solely on pointers representing data in memory.

But data isn’t the only thing residing in memory. All the program code is accessible through either the RAM or some other executable type of memory, giving each function a specific address inside that memory as entry point. Once again, pointers are simply memory addresses, and to fully utilize this similarity, C provides the concept of function pointers. Function pointers provide us with ways to make conditional code execution faster, implement callbacks to make code more modular, and even provide a foothold into the running machine code itself for reverse engineering or exploitation. So read on!

Function Pointers

In general, function pointers aren’t any more mysterious than data pointers: the main difference is that one references variables and the other references functions. If you recall from last time how arrays decay into pointers to their first element, a function equally decays into a pointer to the address of its entry point, with the () operator executing whatever is at that address. As a result, we can declare a function pointer variable fptr and assign a function func() to it: fptr = func;. Calling fptr(); will then resolve to the entry point of function func() and execute it.

Admittedly, the idea of turning a function into a variable may seem strange at first and might require some getting used to, but it gets easier with time and it can be a very useful idiom. The same is true for the function pointer syntax, which can be intimidating and confusing in the beginning. But let’s have a look at that ourselves.

Continue reading “Directly Executing Chunks Of Memory: Function Pointers In C”

A Blockchain, Robotics And AI Event In Vietnam

Blockchain Education Network Vietnam recently held an event titled “Building a Robotics & Artificial Intelligence Ecosystem with Blockchain”. The title alone has three of my favorite things in it, so when a client of mine asked me if I could put together a little hardware demonstration for the event, I jumped at the opportunity.

I also thought I’d take a moment to write about it, because I haven’t seen much coverage of emerging technology events in the developing world, and the fact is that there’s a consistently high level of interest. I’ve yet to go to an event that wasn’t filled to capacity, and I hope to share some of that enthusiasm with you.

Continue reading “A Blockchain, Robotics And AI Event In Vietnam”

Blueprints Make It Easy To Make (Some) Alexa Skills

If you can code, you can create an Alexa skill — the programs that allow an Amazon Echo or similar device interact with you. What if you can’t code or you are just too lazy to do all the setup? Amazon now has Blueprints that can help anyone make a skill. The only problem is the skills you can create are pretty limited. In addition, they are only available to your Alexa devices.

The idea is simple. You start with a template — OK, a blueprint. This is a model application that does something like giving you a compliment or a joke on demand. When you open the blueprint, you’ll see a list of things it can say. You can edit the list, including adding or deleting things. Then you name the new skill. In a few minutes, your skill will be live on your devices.

Continue reading “Blueprints Make It Easy To Make (Some) Alexa Skills”

When 4 + 1 Equals 8: An Advanced Take On Pointers In C

In our first part on pointers, we covered the basics and common pitfalls of pointers in C. If we had to break it down into one sentence, the main principle of pointers is that they are simply data types storing a memory address, and as long as we make sure that we have enough memory allocated at that address, everything is going to be fine.

In this second part, we are going to continue with some more advanced pointer topics, including pointer arithmetic, pointers with another pointer as underlying data type, and the relationship between arrays and pointers. But first, there is one particular pointer we haven’t talked about yet.

The one proverbial exception to the rule that pointers are just memory addresses is the most (in)famous pointer of all: the NULL pointer. Commonly defined as preprocessor macro (void *) 0, we can assign NULL like any other pointer.

Continue reading “When 4 + 1 Equals 8: An Advanced Take On Pointers In C”