Code Craft-Embedding C++: Hacking the Arduino Software Environment

The Arduino software environment, including the IDE, libraries, and general approach, are geared toward education. It’s meant as a way to introduce embedded development to newbies. This is a great concept but it falls short when more serious development or more advanced education is required. I keep wrestling with how to address this. One way is by using Eclipse with the Arduino Plug-in. That provides a professional development environment, at least.

The code base for the Arduino is another frustration. Bluntly, the use of setup() and loop() with main() being hidden really bugs me. The mixture of C and C++ in libraries and examples is another irritation. There is enough C++ being used that it makes sense it should be the standard. Plus a good portion of the library code could be a lot better. At this point fixing this would be a monumental task requiring many dedicated developers to do the rewrite. But there are a some things that can be done so let’s see a couple possibilities and how they would be used.

Continue reading “Code Craft-Embedding C++: Hacking the Arduino Software Environment”

Simone Does Strange Things With Motors and Servos

If DC motors are the “Hello World” of making things move, servo motors are the next logical step. [Simone Giertz] is following this exact path with the Wake-up Machine and her newly released Chopping Machine. [Simone] discovered that the best way to wake up in the morning is to be repeatedly slapped in the face by a robot. The Wake-up Machine was custom designed to do exactly that. Who could sleep through being repeatedly slapped in the face? A beefy gearmotor from ServoCity spins a Halloween prop arm round and round, providing  “refreshing” slaps.

wakeThe system is triggered by an alarm clock. The clock’s alarm output is connected to an Arduino Uno. The Uno then activates a relay, which spins up the motor. [Simone] realizes that she could have skipped the Arduino here, but it was the path of least resistance in for this project. If the slapping hand isn’t enough to get you going, the Wake-up machine does have a secret weapon: It may just grab your hair, turning a video shoot into a painful ordeal.

Simone’s latest project is the Chopping Machine. ServoCity must have liked her first videos, as they’ve sponsored her for this project. The machine consists of two knives that … well, chop. Two high-powered servos are controlled by an Arduino Nano. The servos raise spring-loaded knives, which then drop down, chopping vegetables, fingers, and anything else in their path. The whole machine is built with aluminum channel stock, and a huge wooden cutting board. Of course, just building the machine wasn’t enough. [Simone] filmed a parody infomercial for any perspective Chopping Machine buyers, and to put fear in the heart of anyone named Chad.

Click past the break for a couple of [Simone’s] vlogs describing the machines.

Continue reading “Simone Does Strange Things With Motors and Servos”

IoT Power Strip Lets you Control All Your Holiday Lights

As IoT devices become more prevalent in the consumer world, how long will it be before it’s cheaper to buy one, than to make one? Definitely not yet, which means if you want your very own IoT power strip — you’ll have to make your own. Good thing it’s not that hard!

[Dev-Lab] came up with this project which allows him to control several outlets with his phone. What we really like about it is that he designed a 3D printed housing that fits on the end of the power-strip. This keeps all messy wires out of sight, and it looks like it was designed to be there!

The beauty with an IoT device like this is that it doesn’t require any infrastructure besides a WiFi enabled device with an HTTP browser — the ESP8266 module means no server is necessary. An Arduino was used in the project just because it was quick an easy to do. But it really boils down to being a glorified pin expander. This could very easily be fixed by upgrading from an ESP01 to and ESP03 module to get more IO broken out on the carrier board. If you do this, let us know!

Continue reading “IoT Power Strip Lets you Control All Your Holiday Lights”

$20 Sip-and-Puff Mouse from E-Cig and 3D Printing

At Hackaday, we think the highest form of hacking is hacking for good. Sure, it’s fun to build robots and gadgets, and universal remotes. But it is even better to create things that make people’s lives better. In that spirit, we enjoyed seeing the Assistive Tech Challenge over on Thingiverse that ended last month. The winner was [0_o] who used 3D printing and an Arduino to produce a mouth-operated mouse for under $20.

sip-sensor-from-ecigInstructions on Thingiverse can be spotty, but [0_o] did an excellent job of laying out what you need to buy and how to assemble it. One of the most interesting parts of the build is the blow sensor. [0_o] tore apart a $5 electronic cigarette and used the sensor within. The mouthpiece is moved like a joystick to actuate the cursor, and the user blows into it for the mouse clicks. Perhaps not a true sip-and-puff system but it made us wonder what other uses you might find for these sensors.

You can see a video about the mouse after the break. These kinds of projects have the power to make someone’s life better and what could be better than that?

Continue reading “$20 Sip-and-Puff Mouse from E-Cig and 3D Printing”

Reading Smart Cards from a PLC (with a Little Arduino Help)

If you’ve spent any time on a factory or plant floor, it is a good bet you’ve run into PLCs (Programmable Logic Controllers). These are rugged computers that do simple control and monitoring functions, usually using ladder logic to set their programs. [plc4u] wanted to connect a smart card reader to an Allen Bradley PLC, so he turned to an Arduino to act as a go-between.

The Arduino talks to a USB card reader using a USB host shield. Then it communicates with the PLC using an RS232 link and the DF1 protocol that most Allen Bradley PLCs understand. You may not need a smart card, but once you know how to communicate between an Arduino and the PLC, you could do many different projects that leverage other I/O devices and code available on the Arduino and connects to existing PLC installations. Just remember that you’ll probably need to ruggedize the Arduino a bit to survive and be safe to the same level as a PLC (which might include a NEMA enclosure or even an explosion-proof box).

Continue reading “Reading Smart Cards from a PLC (with a Little Arduino Help)”

Code Craft – Embedding C++: Templates

The language C++ is big. There is no doubting that. One reason C++ is big is to allow flexibility in the technique used to solve a problem. If you have a really small system you can stick to procedural code encapsulated by classes. A project with a number of similar but slightly different entities might be best addressed through inheritance and polymorphism.

A third technique is using generics, which are implemented in C++ using templates. Templates have some similarities with #define macros but they are a great deal safer. The compiler does not see the code inserted by a macro until after it has been inserted into the source. If the code is bad the error messages can be very confusing since all the developer sees is the macro name. A template is checked for basic syntax errors by the compiler when it is first seen, and again later when the code is instantiated. That first step eliminates a lot of confusion since error messages appear at the location of the problem.

Continue reading “Code Craft – Embedding C++: Templates”

Ball Balancing Arduino-Style

If you have a good sense of balance, you can ride a unicycle or get on TV doing tricks with ladders. We don’t know if [Hanna Yatco] has a good sense of balance or not, but we do know her Arduino does. Her build uses the ubiquitous HC-SR04 SONAR sensor and a servo.

This is a great use for a servo since a standard servo motor without modifications only moves through part of a circle, and that’s all that’s needed for this project. A PID algorithm measures the distance to the ball and raises or lowers a beam to try to get the ball to the center.

Continue reading “Ball Balancing Arduino-Style”