Lego Mindstorms Tank Rover with Ultrasonic Sensors
A quick Lego rover using the Mindstorms Robotic Invension System 1.5. This took under 30 minutes to build and program using native RCX Code (and with a little help from my 5 year old). The rover uses an Ultrasonic Proximity sensor coupled to the RCX brick. The Ultrasonic Proximity detector has a range of 30 cm to 2.5 meters. This sensor is capable of detecting distances of objects in front with accuracy of 2-3 cm.
Here is a short video showing the rover avoiding crashing into walls. With the minimum sensor distance being 30 cms, detecting an approaching wall within 30 cms isn’t possible. The ultrasonic sensor is connected to the standard RCX input and configured as a light sensor in the RCX Code.
Sound Activated Flash Trigger for High Speed Photography
The primary problem when designing a sound sensor for a standard ADC input is to convert the amplified sinusoidal waveform into a corresponding stable DC voltage. This circuit here uses a common multimedia desktop microphone as the primary sensor, and a pre-amplifier along with a Arduino micro-controller to trigger an external camera flash.
The feeble 1-3mV signal coming from the Electret microphone is pre-amplified by a single-stage 2N3904 transistor amplifier. The output is then passed through a 10uF Electrolytic capacitor and the rectified by a pair of diodes. This provides a DC output voltage in the range of 0.5V to 3.3V depending on the amplitude of the sound.
The output from the diodes needs to be stabilized for a certain amount of time so that the ADC has enough time to get a sample reading. A simple RC circuit comprising of a 100K resistor and a 0.1uF disc ceramic capacitor is sufficient for this. The output ‘OUT’ can be connected to A0 (Analog pin 0) on the Arduino board.
The 8K2 resistor can be replaced by a 10K resistor. The 10uF electrolytic capacitor on the collector of the 2N3904 has its positive terminal connected to the transistor. The circuit is powered by a regulated 5V supply which can easily be drawn from the main Arduino board.
Triggering the flash is really simple, using a commonly available CNY-17 opto-isolator. Use any digital pin from the Arduino configured as an output and feed that to trigger the internal photodiode. The photodiode cathode should be taken to ground via a 100 Ohm resistor. The CNY-17 datasheet is available here.
The collector and emitter of the internal photo-transistor is connect to the PC sync port of the flash. If the flash doesn’t have a PC port, it can be connected on a Hot-shoe adapter that does.
The software constantly monitors analogue pin A0, and when it crosses a defined threshold, it pulls the output pin high for a brief (about 100ms is fine) time. This is enough to trigger the flash. After the flash fires, its advisable to add a delay of about 1-2 seconds so that stray noises (subsequent bounces/impacts) can be eliminated.
To connect the flash, its best to get a female PC sync cable, cut the other end and then use that to connect to the opto-isolator. Unfortunately, I didn’t have one of those, so had to connect the PC sync port with a bit of engineered PCB hook-up wire. Rustic, but it works until you find a proper cable.
Here is the completed circuit on a breadboard. The circuit works great for dropping coins, marbles, fruits and the like into a glass of water, but the microphone pre-amplifier is just not sensitive enough to detect a single drop of water falling from a height, unless you hold the microphone really close. Am still working on a more sensitive version that should be able to do that. Maybe a LM358 or 741 Op-Amp might provide the needed gain. Some folks have suggested using a standard acoustic microphone along with a guitar amplifier to act as a sound sensor. The output from the guitar amplifier needs to be rectified and stabilized before it can be fed into the Arduino ADC. I’m going to try this out at some point too.
For now, this suffices quite well. Will probably try some cut fruit now…




And here is the software…
/* Sound Activated Flash Trigger * by Sanjib Mitra * * Program using a Electret Microphone Preamplifier * * Listen to analog pin 0 and detect sounds that cross the * defined threshold. This needs to be calibrated depending * on ambient noise. Once detected, the program writes out * a HIGH on digital pin 12 for 100ms to trigger the flash * via an opto-isolator * */ int flashPin = 12; // flash PC sync connected to control pin 12 int soundSensor = 0; // the sound sensor will be connected to analog pin 0 byte event = 0; // variable to store the value read from the sensor pin int THRESHOLD = 5; // threshold value to decide when the detected sound is a knock or not void setup() { pinMode(flashPin , OUTPUT); // declare the flashPin as an OUTPUT Serial.begin(9600); // use the serial port } void loop() { event = analogRead(soundSensor); // read the sensor and store it in the variable if (event >= THRESHOLD) { digitalWrite(flashPin, HIGH); // take flashPin HIGH delay(100); // wait for 100ms to trigger the flash digitalWrite(flashPin, LOW); // take flashPin LOW Serial.println("Flash Triggered\n"); // inform the computer that the flash was triggered delay(10); // 10ms delay to avoid overloading the serial port } }
This article was inspired by and based upon experiments described here. Thanks Glacial Wanderer!
Wireless Rover with ATMega32 AVR Brain
A few years ago, I tried to build a wireless rover using a 40-pin ATMega32 Atmel Microcontroller and an old Nikko R/C Jeep. This was something of a continuation project from my days in university. The board was from Futurelec, and it was a pretty handy little board with a bunch of ports. I don’t think they sell that anymore, and its now been succeeded by more advanced AVRs. A good replacement would be this board.
Essentially, the motors from the R/C Jeep were reused by replacing the original DC motor control circuits with a dual H-Bridge DC motor control module. The inputs to the H-Bridge; 2 inputs for each motor were directly driven by PORTC of the ATMega board. 1 motor for the main drive and another for the steering, which is the standard configuration for most R/C cars. If you don’t have the time to build your own, you can get a pre-assembled Dual Motor Driver from Robokits India at about Rs 300.
A BlueSMiRF Bluetooth Modem was connected to the onboard USART on the ATMega board and mounted vertically. Two sets of power needed to be used, 6V for the motors and driver circuitry and a 9V supply (regulated to 5V) for the ATMega board and BlueSMiRF module.
The sensors were quite simple. Micro switches attached to the bumpers and an ultrasonic distance meter buried under the board with its sensors peeping through.
The software on the ATMega board was in C and included modules to scan the sensors constantly, send status to the host computer via Bluetooth and most importantly, receive commands from the host computer via Bluetooth. The host computer control center comprised of a browser application that would run Java Server Pages which in turn communicated with the rover over a Bluetooth COM port. The host computer software was Java at its core with a little bit of JSP and Ajax for the User Interface.
The finished rover was somewhat crude, but hey, it worked well enough. Manual control and navigation was possible from the internet thanks to JSP, and the sensors could be read directly off the rover; first via the internet and then locally over wireless Bluetooth. The possibility of adding a webcam and then streaming live video onto the internet did occur, but the R/C Jeep chassis and the available power would be a bottleneck.
Some more photos of the Bluetooth wireless rover below…
List of Electronic/Robotic Hobbyists Online Stores
Here is a brief rundown of some online shops in India that cater to electronic and robotic hobbyists. The list is by no means complete. These online shops sell everything from development boards to resistor packs.
This list will be updated from time to time, as new stores are added and reviewed.
http://www.sunrom.com
Good guys, good stuff. Wide range of boards, modules and sensors. The first place to shop online. Decent website. Prices slightly on the higher side.
http://www.robokits.co.in/
Overall good site, a few inspired products. Wide range of power options and batteries for robotic applications.
http://www.triindia.co.in/shop/
Good selection of products here, including some standard robot kits. Website could use an overhaul. Prices are decent.
http://www.vegakitindia.com
Yes, they are still in business. Had so much hope for these Mumbai folks for over 15 years, but they never fail to disappoint. The website is horrid, browsing and buying is equally so. Not recommended unless you really want that sleazy sounding musical doorbell kit.
Some of the kits are okay for starters, especially the audio and light kits. Probably some other useful modules too, just that their presentation is very poor and to top that the website is very slow as well. Downloading their PDF catalog and browsing offline is the only way to go here. Vega Kits are a classic example of how a company can plunge downward if it fails to adapt. These guys are still living in the past.
http://www.robosoftsystems.co.in
Some well selected items available here. The website is good and buyer friendly, easy to browse. Slightly expensive, but they do have some unique stuff here. They sell the SageBot and some Solar Robots too. Their range of sensor modules is very good. Worth a visit.
http://www.deccanrobots.com
Some nice compact modules and boards here that you won’t find anywhere else. Poor website, but okay price wise. Checkout their useful 5V DC Regulated modules, a steal at Rs 36.
http://www.simplelabs.co.in
Limited items here, but they do however sell the Induino. Induino is “The Cheapest Arduino USB Clone Board with 100% Shield Compatibility”. They also stock the original Italian made Arduino, some DC/stepper motors and development kits. Thats about all.
http://www.makemyhobby.com
This is a generic hobby site. One of those places where you never know what you might find. Items ranging from silly to serious. The website is quite pathetic.
http://bhasha.co.cc/
These folks sell Arduino and Freeduino boards and accessories. Some good Arduino shields here too, like the XBee shield and the Motor Driver shield. Website is good, prices are slightly high. Even though they don’t have a proper payment gateway, they do accept Paypal (for payments in USD). In order to pay in INR, you will have to separately wire the money or use any one of the traditional payment methods.
The buying experience from Bhasha was a pleasant one. They are very professional, and provide constant email updates about the status of your payment/order. Items are well packed, and delivered on time.
http://www.robotz.in
Good place for electro-mechanical robot components. Small selection, and template OSCommerce website is a downside.
Lots of nick knacks, wide range of useful components. Never know what you’ll find here at a bargain. Their 4 Channel RF Controller Board is very recommended. The website has some issues, and they do not have a payment gateway in place. I just wish they would have a wider variety of components; sometimes would find a 4K7 preset but there’s no sign of a 47K. Lots of other essential components missing.
http://feemo.in
Great looking site, super products and fantastic service. Official Sparkfun distributor in India. They accept Paypal for payment in USD. Still no sign of a proper payment gateway. Buying experience is however quite good.
http://www.robonics.co.in
Probably a dozen products, nothing of much interest here. Maybe worth a look if you are into vintage robotics. The most interesting product here is the Long-Nosed Pliers.
http://www.technophilia.co.in
Stock only a handful of development boards, sensors, motors and specialized ICs. Prices are okay, but buying and checking out is very painful.
http://www.tenettech.com/
These guys are the best. A wide range of boards and sensors. Exceptional service and a decent website. They are also a SparkFun distributor. Definitely worth a visit.
http://www.rcdhamaka.com/
Just what the name says. Cars, planes, helicopters, wheels, propelors, blades, motors, radios and those difficult to find R/C components. Yes, its true, you can buy them right here now. Limited stock, but none the less, a good start.
The official EFY (Electronics For You) online kits and spares outlet. Initially I couldn’t tell if its an online museum of internet history or an actual online shop. Anyway, they have some good kits, if you can find them. Buying is tedious.
Getting started with the BlueSMiRF module
SparkFun’s BlueSMiRF Bluetooth Modem is an excellent wireless serial cable replacement. It has a very small form factor and is really easy to use. It comes with an in-built antenna and can handle any data rate from 9600 to 115200bps. Add one of these modules to your micro-controller project for instant Bluetooth connectivity.
To get your hands on one of these in India, check out Feemo, Sparkfun’s official India distributor. They also have a range of sensors and other goodies. They seem to be in big demand, as the Feemo store is often out of stock for this particular product.
I got one of these directly from SparkFun, and is the slightly older v1 which has the same physical characteristics as the new ‘Gold’ version but employs a different Mitsumi Bluetooth module. The operation is mostly the same, but has a few differences for configuration.
Setting up one of these units is fairly straightforward. The module has only 6 electrical connections to wire up (of which 2 need not be used). Follow the instructions below to enable a serial USART or UART enabled micro-controller to be hooked up to this:
- Connect the PWR and GND on the BlueSMiRF module to 5V and Ground respectively
- Connect Transmit TX-O on BlueSMiRF to the RX pin on any micro-controller
- Connect Receive RX-I on BlueSMiRF to the TX pin on any micro-controller
- CTS-I and RTS-O are used for hardware flow control and can be connected to each other when not used
That’s it, in terms of connectivity for hardware. By default, the BlueSMiRF is set up to work with 9600 bps, but can be changed from the configuration mode.
To test this module out, you will need a PC laptop/desktop with either built in Bluetooth or you use any commonly available Bluetooth dongle. Then do the following:
- Make sure you power on your micro-controller and ensure that the BlueSMiRF is also powered. A lit green LED on the BlueSMiRF should indicate power.
- Search for Bluetooth devices on the PC. The BlueSMiRF module should show up as ‘BlueRadios‘. Device category will be unknown, which is fine
- Once detected, you can pair with it. The default PIN is ‘default‘. Windows will assign a COM port to the Bluetooth module. Once paired or connected, the green LED on the BlueSMiRF module changes to red.
- Fire up Hyperterminal with 9600/8/N/1 settings and you should be connected to the BlueSMiRF module. Note that the terminal will not echo local characters, so you will need to do this in the terminal setup
- To enter command mode, type in +++ followed by the Enter key…
+++<cr>
and you should see the response…
OK
To see the friendly name of the BlueSMiRF module type ATSI,2 followed by Enter. The factory default name is BlueRadios. This can be easily changed. To change the name to BLUE_WONDER simply type ATSN, BLUE_WONDER followed by the Enter key.
ATSN, BLUE_WONDER<cr>
OK
There are loads of other configuration parameters that can be set in command mode. To get back to the data mode, type in ATMF<cr> for fast-mode or ATMD<cr> normal-mode. Thats how simple it is to add Bluetooth to your project!







1 comment