Saturday, November 21, 2015

Arduino Controlled Adjustable Constant Current Source

Did you know you could use the Arduino to control the amount of current from a constant current source? Another great project from Henry's Bench, this experimental project uses an MCP4725 Digital to Analog Converter, an LM358 Op Amp, an INA219 Current Sensor and a logic level N-Channel Mosfet to create a constant current source. You can program up to 3 amps of constant current.

Hot Tentacle Action

What happens when you combine an arduino, a servo, and a rubber tentacle. Well, it could be madness, or it could be a knife wielding tentacle bot. Either way it's a conversation starter, or ender.

More servo fun at:

Thursday, November 19, 2015

Processing Now Optimized for the Pi

Thanks to the new Hardware I/O libraries, Processing is now optimized for the Raspberry Pi. This makes it much easier to use the Raspberry Pi I/O pins, and send data back and forth with a Arduino.

Hardware I/O
The Hardware I/O library allows to access the computer's hardware peripherals, such as digital inputs and outputs, serial busses, and the like, in a fashion similar to the Arduino platform. This library is only available for embedded Linux boards with the necessary kernel drivers, such as the Raspberry Pi.

Considerations and limitations can be found at

New Processing / Raspberry Pi Tutorial -

boolean ledOn = false;

void setup() {
  GPIO.pinMode(4, GPIO.OUTPUT);

  // On the Raspberry Pi, GPIO 4 is pin 7 on the pin header,
  // located on the fourth row, above one of the ground pins
  // For this particular board one could also write:


void draw() {
  ledOn = !ledOn;
  if (ledOn) {
    GPIO.digitalWrite(4, GPIO.LOW);
  } else {
    GPIO.digitalWrite(4, GPIO.HIGH);
  ellipse(width/2, height/2, width*0.75, height*0.75);

Sunday, November 15, 2015

WiFi Rechargeable Internet Clock

Many moons ago we built a Ethernet enabled clock that got it's time updates from a Internet NTP Server. We have updated that project for WiFi,and added a rechargeable battery that can be recharged with a USB cable. Now just need to add alarm and snooze functions! Review this project, and many more of our Instructables at

This project uses a Arduino UNO, a Arduino WiFi shield, a Adafruit Powerboost 500 Lithium battery shield, and a Adafruit RGB I2C LCD Keypad shield. Code and libraries for both versions of the clock found at Instructables.

Thursday, November 12, 2015

The Maker's Guide to the Zombie Apocalypse

Defend Your Base with Simple Circuits, Arduino, and Raspberry Pi

Where will you be when the zombie apocalypse hits? Trapping yourself in the basement? Roasting the family pet? Beheading reanimated neighbors?

No way. You'll be building fortresses, setting traps, and hoarding supplies, because you, savvy survivor, have snatched up your copy of The Maker's Guide to the Zombie Apocalypse before it's too late. This indispensable guide to survival after Z-day, written by hardware hacker and zombie anthropologist Simon Monk, will teach you how to generate your own electricity, salvage parts, craft essential electronics, and out-survive the undead.

Read and approved by the Guru's at Arduinotronics! For kids and adults alike.

Friday, November 6, 2015

Plotting Light Levels With Arduino 1.6.6

Long ago in a galaxy far away, we built a simple CdS Light Sensor (Sometimes called a LDR). Now with the real time plotting capability of Arduino 1.6.6, it's even more fun! The original project requires no changes, just pick Serial Plotter from the Tools menu.

CdS Photoresistor -
10k Resistor -

Code -

Plotting Temperature -

Thursday, November 5, 2015

Plotting Temperature with Arduino 1.6.6

One of the new features of Arduino1.6.6 is the ability to plot data. In this example, I have taken a DHT-11 temperature sensor, and I'm sending the data to the serial plotter (found on the Tools menu). You can only have one axis of data, so I have a single serial.println in the code.

I'm using a DHT-11 module that comes on a breakout board with the resistor all ready added. You will need the DHT library found at I plugged the module directly into the Arduino, so the data pin is connected to Arduino pin 6, - is connected to Arduino Pin 7, and +5 is connected to pin 5. You will see in the code where I'm sending digitalWrite commands to pins 5 and 7 sending a high and a low respectively, powering the module. Because I'm taking a reading every 2 seconds (it's a slow sensor) the serial plotting crawls very slowly across the screen.

#include "DHT.h"

#define DHTPIN 6     // what digital pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)


void setup() {
  pinMode(7, OUTPUT);  
  pinMode(5, OUTPUT);  
  digitalWrite(7, LOW);
  digitalWrite(5, HIGH);
  //Serial.println("DHTxx test!");


void loop() {
  // Wait a few seconds between measurements.

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    //Serial.println("Failed to read from DHT sensor!");


Monday, November 2, 2015


The typical LCD used with an Arduino has 16 pins. only 6 of them have to use a I/O port on the Arduino. But what if you could get that down to two I/O pins, and still have those pins available for other devices? The I2C interface is on pins A4 and A5 of the Arduino. These have addresses, and are therefore shareable with other I2C devices that have different addresses.

Now, you can buy I2C LCD's, and you can even find I2C LCD's with different addresses, but they are typically two line LCD's, and the addresses are fixed. I'm going to show you how to build your own I2C interface, select one of 8 addresses, and even be able to add up to 8 inputs, using a MCP23017 16 port expander chip.

This is the same chip Adafruit uses on their I2C LCD Keypad Shield, and uses their library to talk to it. First let's look at the wiring. The connections between the Hitachi type parallel LCD (2 or 4 line) and the MCP23017 are shown below. Pins 15, 16, and 17 on the MCP23017 determine the I2C address. We have all 3 grounded, as this is the default address the Adafruit library uses. To add multiple displays, or pick another address, the library will have to be modified, so we will go with the default in the this example.

Notice the 220 Ohm resistor on the LCD k (cathode, gnd) connection. This is a MUST! Without it, you can blow the backlight pin on the MCP23017.

SDA (pin 13 on the MCP2307) connects to Arduino A4 and SCL (pin 12 on the MCP2307) connects to Arduino A5.

Download and install the Adafruit library, run the example "Hello  World", and this lcd interface is operational. We will address adding inputs to this chip, and editing the library address so that up to 8 MCP23017 chips can be used in a future article. Email me with questions.

Address hint:
Adafruit_MCP23017.h contains 
#define MCP23017_ADDRESS 0x20
Pin 17 = A2, Pin 16 = A1, and Pin 15 = A0
0 = ground, 1 = +5v
The address format is 0100A2A1A0, so since we have grounded all 3 lines, we are using binary 0100000, or 20 in hex. 0100111 would be 27 in hex.

Now figure out how to pass the address when initializing MCP23017.h ......

So, what is next? 16 channel relay boards with jumpers for address selectors? Maybe seven segment LED controllers?

Thursday, October 29, 2015

Happy 46th Birthday, Internet!

46 years ago today was the first remote transmission between two computers using TCP/IP. You have come a long way baby!

In the glow of a green monochrome screen deep in the bowels of the computer science department at UCLA, a young graduate student (Charley Kline) picked up his phone and called the computer lab at Stanford. He is preparing to send the first message over an Internet connection. The men on either end of the phone are Charley Kline and Bill Duvall.

Thank you Leonard Kleinrock, Charley Kline and Bill Duvall, it was the start of a beautiful friendship. 

Wednesday, October 28, 2015

Add up to 128 Inputs, Outputs, or a mix to your Arduino or Raspberry Pi

The MCP23017 is a very useful chip. This I2C device can be wired for 8 unique addresses, and offers 16 inputs, 16 outputs, or 8 of each. A one stop chip for all needs.

You can talk directly to the chip, or use widely available libraries to insulate your experience from the nitty gritty.

Tronixstuff has a fantastic Arduino tutorial which covers a non library implementation. Very easy to understand, you may wish to avoid a library altogether.

Adafruit has a great Raspberry Pi tutorial to get you up to speed with a great increase in I/O capability, as well as allowing 5v I/O where the Raspberry Pi would only accept 3v inputs.

These can be used to convert a parallel lcd to I2C, and give button inputs as well. Adafruit makes a lcd button shield using this functionality. Build your own at

Drive this 16 channel relay board -

Sunday, October 25, 2015

Arduino Ethernet Cable Tester

As a network engineer, I never go anywhere without my Ethernet cable tester. That and a audible cable finder (fox & hound) are invaluable for finding and testing cable pairs. Today I'm showcasing a Arduino Ethernet cable tester. This tester is switchable for a straight through or crossover test. Test results are seen in a ordered line of LED's, as well as serial output that could be displayed on a LCD and written to a sd card.

A Arduino fox and hound will come  later, and then maybe a TDR distance to fault tester. We will see.

Sunday, October 18, 2015

Temp / Voltage Without Sensors

The Arduino UNO (and 328 clones) has the ability to report the rail voltage and temperature of the chip. You don't need any additional wiring or sensors, just the Arduino itself. The temperature is not very accurate, and reports in Celcius, so we added a "adjustment" factor until it read room temperature, and converted to Fahrenheit. This is a fun "ok, I made it blink, now what" project.


void setup()

void loop() 
 float volts = readVcc();
 Serial.println(" VDC");

 float temp = readTemp();
 temp = temp/1000;
 temp = temp + 25.7; //adjustment 
 temp = (temp * (9/5)) + 32; //conversion to fahrenheit
 Serial.println(" F");

long readVcc() {
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1126400L / result; // Back-calculate AVcc in mV
  return result;

long readTemp() {
  long result;
  // Read temperature sensor against 1.1V reference
  ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = (result - 125) * 1075;
  return result;

Friday, October 9, 2015

Arduino Flood Level Monitor

Since half of South Carolina is under water, and the levels keep increasing each day, I decided to modify our fuel and cistern fluid level project to a flood level monitor. We start with a eTape level sensor from Milone Technologies. You could connect this to a ethernet or wifi shield, or even a gsm shield to notify you of water levels.

Their website lists up to 32", but longer units are available.

Connect to an available analog input. Different length sensors have different resistance values which we will enable in the code.

So, with pin 1 to +5, pin 2 to Gnd, and pins 3 & 4 to Arduino analog in:

int sensorPin = 0; // select the analog input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
float h; // variable for height of liquid

void setup() {

void loop() {
sensorValue = analogRead(sensorPin);
Serial.print(sensorValue); //actual adc value
Serial.println(" ADC");

// Uncomment one of the lines below to match your sensor
//h = mapfloat(sensorValue, 215, 512, 8, 0) //8"
h = mapfloat(sensorValue, 170, 512, 12, 0); //12"
//h = mapfloat(sensorValue, 93, 512, 24, 0); //24"
//h = mapfloat(sensorValue, 75, 512, 32, 0); //32"

Serial.print(h, 2); // fluid height (inches)
Serial.println(" inches");
delay(5000); //how long between measurements

float mapfloat(float x, float in_min, float in_max, float out_min, float out_max){
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

Monday, October 5, 2015

Simple Seven Segment LED Displays

Seven Segment LED's are a common method of displaying data. With 8 datapins, they are also complicated to wire up, as each LED needs a Arduino pin and a resistor. With a library, we can simplify the wiring, and the data display. Typical displays look like the following:

To reduce the number of Arduino connections if we want to use multiple digits, we will connect all the a segments together, all the b segments together, all the c segments, and so on. We will have a data line for each common so we can light up each segment with different data.

So here goes, connect a 330 ohm resistor to Arduino pin 2. then connect the other end of that resistor to segment a on each module. Follow the chart for the other pins.

Arduino pin 2 -> 330 ohm resistor -> all segment a's
Arduino pin 3 -> 330 ohm resistor -> all segment b's
Arduino pin 4 -> 330 ohm resistor -> all segment c's
Arduino pin 5 -> 330 ohm resistor -> all segment d's
Arduino pin 6 -> 330 ohm resistor -> all segment e's
Arduino pin 7 -> 330 ohm resistor -> all segment f's
Arduino pin 8 -> 330 ohm resistor -> all segment g's
Arduino pin 9 -> 330 ohm resistor -> all segment p's (decimal Point)

1st module com to Arduino pin 10
2nd module com to Arduino pin 11

You will need to download and install the library from

Now the code:

#include "SevSeg.h"

SevSeg sevseg; //Instantiate a seven segment controller object

void setup() {
  byte numDigits = 2;   // number of modules
  byte digitPins[] = {10,11}; // where your common pins are connected
  byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8, 9}; //where your segments pins are connected

  sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins); //Use COMMON_CATHODE if your modules use gnd on the common, or COMMON_ANODE if they take positive on the common.

void loop() {
  int d1 = 12; // number you want displayed, usually from a sensor
  sevseg.setNumber(d1, 1); //display number, with optional decimal point (1 place)

  sevseg.refreshDisplay(); // Must run repeatedly

/// END ///

More info at

Thursday, October 1, 2015

Arduino WiFi Shield 101 - SSL for $50

Arduino WiFi Shield 101 is a powerful IoT shield with crypto-authentication that connects your Arduino or Genuino board to the internet wirelessly. Connecting it to a WiFi network is simple, no further configuration in addition to the SSID and the password are required. The WiFI library allows you to write sketches which connect to the internet using the shield.

The shield is based on the Atmel SmartConnect-WINC1500 module, compliant with the IEEE 802.11 b/g/n standard. The WINC1500 module provided is a network controller capable of both TCP and UDP protocols.  The main feature is an hardware encryption/decryption security protocol provided by the ATECC508A CryptoAuthentication chip that is an ultra secure method to provide key agreement for encryption/decryption, specifically designed for the IoT market.

The WiFi Shield 101 is the first Arduino product fully supporting SSL and all the communication between your board and a secured server. With the power of the Arduino Zero and the WiFi Shield 101 it is possible to make secure IoT applications simply and just using the Arduino Language.