Friday, December 20, 2013

Actobotics, not your Father's Erector Set

Sparkfun announces Actobotics, a full line of gears, motors, mounts and more! There is just about every size of gear, tube, or shaft that you need. Additionally, instead of plastic, they opt for aluminum or stainless steel, and use ball bearings instead of relying on plastic bushings. Lastly, we really like the fact that nearly all of the products work seamlessly with one another. Actobotics products use either a 0.77" or 1.5" hole pattern, allowing you to easily connect a gear to your servo, and then connect your servo to one of the channels or beams.


https://www.sparkfun.com/news/1345

Friday, December 13, 2013

2 Million Instructables Views!

We are coming up on 2 million Instructable views. I have a extra special set of freebies for everyone that emails us (sspence@green-trust.org) on the day it trips! Just drop us an email with your thoughts, and you get the goodys!

Thursday, December 12, 2013

Digital Soldering / Desoldering Station

I was able to play with the new Weller WXD 2020 Soldering / De-soldering Station today. I've been using de-soldering tools almost all my life, but none of them compare to this one. 8 pin relays just fell out of the board by themselves, and new ones slipped right in the perfectly clean holes. This truly is an amazing machine!

Touch screen, "Ipod" type shuttle, and two programmable settings for both soldering and de-soldering. 1/4" air line to connect to shop air.  Adjustable air delays to make sure all the solder is removed and the "sucker" stays unclogged.

New WXD soldering and desoldering system has an array of configurable features.


WXD2 Soldering/Desoldering Station
This new addition to the WX series provides maximum temperature precision and optimal performance in load situations. 255W digital soldering/desoldering station can operate two 120W irons simultaneously, and is compatible with all WX series tools. Liquid crystal graphic display with wheel and click navigation. Modular flexibility lets you expand and control up to two peripheral devices like fume extractors or heating plates. External compressed air input with built-in pressure sensor maintains stable desoldering vacuum. Built-in multi-purpose USB port. Configurable settings include temperature, LCD contrast and brightness, language, password, screensaver, standby temperature and sleep time.

WXDP 120 Desoldering Iron
Energy saving, cost-effective 120W desoldering iron reaches operating temperature in 35 seconds. Bayonet fitting of the disposable solder cartridge means quick and easy changes, without the risk of burns. ON/OFF switch located in ergonomic hand grip. Temperature range: 150 - 850°F (50 - 450°C).

I am very impressed with this equipment, and it will greatly reduce time on task, and damage to boards.

Monday, December 2, 2013

Temp / Humidity w/ Dew Point Calculations

I've taken our older Temperature / Humidity project, and updated it with Dew Point Calculations.

Update: added Heat Index calculations!

"The dew point is the temperature below which the water vapor in air at constant barometric pressure condenses into liquid water at the same rate at which it evaporates. The condensed water is called dew when it forms on a solid surface."
So, I've added a new function at the end of the script that makes the calculations, defined some new variables in the sketch, and made some calculation and new prints in the loop. Enjoy!

Parts:

1 DHT-11 Temp / Humidity Sensor
1 Arduino Uno
1 10k Resistor

I suggest a solderless breadboard for testing:
Breadboard with jumper wires

(wiring diagram and library download at http://learn.adafruit.com/dht/overview)


Wind Chill option (need a wind speed sensor)


// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include <DHT.h>

#define DHTPIN 2     // what pin we're connected to

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

// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);

float tF;
float dP;
float dPF;

void setup() {
  Serial.begin(9600);
  Serial.println("DHTxx test!");

  dht.begin();
}

void loop() {
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  } else {
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    // Serial.print(t);
    // Serial.print(" *C ");
    tF=((t*9)/5)+32;
    Serial.print(tF);
    Serial.print(" *F ");
    Serial.print(" \t");
 
  Serial.print("Dew Point: ");
  // Serial.print(dewPointFast(t, h));
  // Serial.print(" *C ");
  dP=(dewPointFast(t, h));
  dPF=((dP*9)/5)+32;
  Serial.print(dPF);
  Serial.print(" *F");
  Serial.print(" \t");

  Serial.print("Heat Index: ");
  Serial.print(heatIndex(tF,h));
  Serial.println(" *F");


  }
}

// delta max = 0.6544 wrt dewPoint()
// 6.9 x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
double Td = (b * temp) / (a - temp);
return Td;
}

double heatIndex(double tempF, double humidity)
{
  double c1 = -42.38, c2 = 2.049, c3 = 10.14, c4 = -0.2248, c5= -6.838e-3, c6=-5.482e-2, c7=1.228e-3, c8=8.528e-4, c9=-1.99e-6  ;
  double T = tempF;
  double R = humidity;

  double A = (( c5 * T) + c2) * T + c1;
  double B = ((c7 * T) + c4) * T + c3;
  double C = ((c9 * T) + c8) * T + c6;

  double rv = (C * R + B) * R + A;
  return rv;
}

Saturday, November 30, 2013

The Ultimate Arduino Prototyping Kit

Recently a buddy of mine sent me a kit of his new Arduino prototype board. This kit has a "you build it" arduino on board, and gobs of convenient prototyping space. It took about an hour to assemble the board, and it was ready to accept a project. I have an idea about what I want to put on it, but that will have to wait for a future blog post. It was a lot of fun, and all the components are throughhole, so it was an easy build. All the parts necessary were included, you just supply the solder and soldering iron.

These sell for $20. We are taking interest polls right now (need 50 to order), so if you want one of these, drop us a line and we will let you know as soon as we get a batch in. greentrust@gmail.com

Monday, November 25, 2013

The Arduino VGA Interface - Part 2

We have our VGA Smart Display Controller operational. We started this project with our first post, and now continue with part 2.

The Smart Interface was built, the display code uploaded, and a test pattern is being displayed on our 42" TV using the PC (VGA) interface.

We are using Nick Gammon's Color VGA Sketch and Timer Library. (more background info on Nick's awesome VGA work - http://www.gammon.com.au/forum/?id=11608 )

The next step is the host Arduino sending display text and commands to the display controller. Stay tuned!



Sunday, November 17, 2013

Working with BlueTooth

After some false starts with a couple of HC-06 BlueTooth modules (slave only), we received a HC-05, which can be set for master or slave. Future articles will show two such equipped Arduino's passing data back and forth. Out of the box, it's set for 9600 baud, and a pairing code of 1234. I connected TX on the BT module to Pin 10 on the Arduino, and RX to Pin 11. I connected 5.0 on the BT module to Arduino 5v, and Gnd to Gnd. Some BT modules require a voltage divider to bring the 5v down to 3.3v. This module does not need it, it's 5v friendly.

One of the first things I noticed, was that no LED's light up, but since the device showed up when discovering BT devices, I pushed forward.

Since I'm running Windows 7, I downloaded TerraTerm to connect to the BT Module wirelessly. If your laptop does not have BlueTooth, you can get a $2 USB adapter here.

First, make sure you pair successfully. HC-05 showed up in my discovered bluetooth device list. My Terraterm found two com ports, 11 and 12, but uses 11 to receive data from the Arduino.

I uploaded the following sketch to the Arduino which is transmitting data from the Arduino wirelessly to my laptop (and to my android smartphone as well):

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

int x=0;

void setup()
{


  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);

}

void loop() // run over and over
{
mySerial.println(x);
x++;
}


Re-programming the HC-05 - http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/

Uploading sketches over Bluetooth - http://letsmakerobots.com/node/30915





Tuesday, November 12, 2013

Arduino based DC Generator controller and Alternator Regulator

One of our diy generator members posted a extremely cool marine generator / load control unit based on an Arduino. We are very impressed, and wanted to share their project with you. It manages charge control, load control (including their water maker), and much more.


Arduino based DC Generator controller and Alternator Regulator

Sunday, November 10, 2013

Ultrasonic Range Finding

Yesterday I got a Sainsmart HC-SR04 Ultrasonic Distance Sensor. This is a very simple to use and very inexpensive sensor that gives accurate range readings up to 400cm or so.

There are 4 wires to connect:

Gnd
Vcc (5vdc)
Trig (any digital pin)
Echo (any digital pin)

In this example, we will use pins 11 & 12.

You need to download and install the Newping Library from https://code.google.com/p/arduino-new-ping/

Then upload the following sketch. This sketch takes the height and radius of a cylinder in centimeters, and outputs a fluid level in liters. The concept here is for a cistern. It tells you how many liters of water are left.

#include <NewPing.h>


#define trigPin 12
#define echoPin 11

const float height = 12.7; //cm
const float radius = 3.81; //cm
float totalCap;
float emptyCap;
float filledCap;

NewPing sonar(trigPin, echoPin);

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

void loop() {
  int distance = sonar.ping_cm();
  //Serial.print(distance);
  //Serial.println("cm");
  totalCap =(3.142*(radius*radius)*height)*0.001; //Liters
  emptyCap=(3.142*(radius*radius)*distance)*0.001; //Liters
  filledCap =totalCap-emptyCap; //Liters
  Serial.print(filledCap);
  Serial.println("Liters Remaining");
  delay(500);
}

Saturday, October 26, 2013

Arduino Bluetooth to Bluetooth Communication

Our Bluetooth project will have two Arduino's talking to each other. This will allow us to have a weather station remote talk to the indoor display system. These modules only accept a 3.3v RX signal, so I added a voltage divider to prevent the Arduino 5v signaling from damaging the module. I have the two modules connected to their repective Arduino's, and set the baud rate and pairing codes using a AT Command sketch. Not successful transmitting data bluetooth to bluetooth yet, but am able to pair from my laptop and my Android phone.

Update! With the help of Mike McRoberts, we found the problem. We have 2 identical HC-06's which are hard coded master or slave from the factory. What we need are the HC-05's, which are field settable for master or slave.

Code available!






Friday, October 25, 2013

Arduino to MySQL Direct Part 2

Chuck has come out with an update to his MySQL connector - http://drcharlesbell.blogspot.com/2013/10/introducing-mysql-connectorarduino-100.html

There is a new release of the Connector/Arduino on Launchpad! See https://launchpad.net/mysql-arduino. The new version supports a number of refinements and a few new features. These include:

  • Improved support for processing result sets
  • Conditional compilation to omit result set handling features to save program space
  • Support for the Arduino WiFi shield
  • New version() method to check version of the connector
  • Simplified download (no more patching SHA1!)

So What is It?


If you have never heard of Connector/Arduino, it is simply a library designed to allow the Arduino platform to connect to and issue queries to a MySQL Database server.

Simply add an Ethernet shield to your Arduino and use the library to connect your Arduino to a MySQL database server. Yes, no more web-based hand waving or third party systems! Cool.

Tuesday, October 22, 2013

Arduino OBD-II Vehicle Diagnostics

A buddy of mine wants insight into how his vehicle is performing as he drives. He sent me a ArduinoDev ODB-II interface (model B) and said "figure it out". So here we go! We will be exploring the onboard features in future posts, and hopefully some of the options available for this interface.

Let's start with what's included:

  • Directly pluggable into vehicle’s OBD-II port
  • Serial data interface (UART or I2C)
  • Regulated DC 5V output (300mA for model A, 1A for model B, powers the Arduino)
  • Accessing all OBD-II PIDs available in the vehicle ECU
  • Embedded MPU6050 accelerometer, gyro, and temperature (model B only).
  • SD Datalogger Shield 
Optional ports for a GPS and OLED Display. There is a bluetooth version as well, but this model doesn't have that.





Monday, October 21, 2013

The Arduino VGA Interface

Many of our projects need more in the area of displaying data, so we are putting together a VGA interface. Now the Arduino is pretty under powered when it comes to producing a video signal. so we are using our smart interface concept, and dedicating a DIY Barebones Arduino to producing the video signal, offloading that function from the host micro controller. It's very low resolution, and only 16 color, but will work with any VGA monitor or vga enabled TV. Follow along as this project progresses. For a high resolution, high color version, see http://www.instructables.com/id/Interfacing-a-Digital-Micrometer-to-a-Microcontrol/

If you would like to participate in the development process, I will send you a prototype version for $30, and replace it with the commercial board when it's produced. Email me at solar@essnmag.com






Monday, September 30, 2013

Arduino Temp / Humidity Web Server


A buddy of mine wants to monitor the temperature and humidity levels (among other things) in his dog kennels. I connected a Ethernet Shield to an Arduino, added a DHT-11 Temperature / Humidity Sensor, and whipped up a sketch that runs a web server on the Arduino, serving up the temperature and humidity to a users web browser. You could web enable any device in your home in this fashion! For the outside world to see the device, you would have to enable Network Address Translation (NAT) on your home router, and subscribe to a Dynamic DNS (DDNS) Service, but this is not that complicated.

Connect the DHT-11 as shown above, using a 10k resistor as a pull-up between data and +5v.

Saturday, September 28, 2013

Arduino Keyboard Shield - Part 3

The PS/2 Keyboard Smart Shield prototype is operational!

Now on Instructables!

This is Part 3 in the series.

The Atmel 328P DIY Arduino is reading a PS/2 Keyboard, converting the scan codes to characters, and transmitting the characters to the host Arduino. This removes the burden (memory and cpu cycles) from the host, as it only has to read in characters on a serial port. You can download the code (and the library) from

http://tinyurl.com/n4altnw

This is our first of our "SmartShields". Stay tuned for other intelligent shields!

To help us get this shield to production, please order this prototype interface as shown (keyboard not included) for $30


Arduino Keyboard Shield - Part 2

Continuing from Arduino Keyboard Shield - Part 1, we now have keyboard input from a PS/2 keyboard displaying in the serial monitor. The next step will be building the Smart Shield, which contains a ATMEL 328P running the following code, and the keyboard interface, and sends the received data to the main Arduino.

You will need to download the library and run the included example "Simple_Test". We changed the Interrupt and Data numbers in the example to 3 & 4 respectively.

/*  PS2Keyboard library example

  PS2Keyboard now requries both pins specified for begin()

  keyboard.begin(data_pin, irq_pin);

  Valid irq pins:
     Arduino:      2, 3
     Arduino Mega: 2, 3, 18, 19, 20, 21
     Teensy 1.0:   0, 1, 2, 3, 4, 6, 7, 16
     Teensy 2.0:   5, 6, 7, 8
     Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
     Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
     Sanguino:     2, 10, 11

  for more information you can read the original wiki in arduino.cc
  at http://www.arduino.cc/playground/Main/PS2Keyboard
  or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html

  Like the Original library and example this is under LGPL license.

  Modified by Cuninganreset@gmail.com on 2010-03-22
  Modified by Paul Stoffregen June 2010
*/
 
#include "PS2Keyboard.h"

const int DataPin = 4;
const int IRQpin =  3;

PS2Keyboard keyboard;

void setup() {
  delay(1000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(9600);
  Serial.println("Keyboard Test:");
}

void loop() {
  if (keyboard.available()) {
 
    // read the next key
    char c = keyboard.read();
 
    // check for some of the special keys
    if (c == PS2_ENTER) {
      Serial.println();
    } else if (c == PS2_TAB) {
      Serial.print("[Tab]");
    } else if (c == PS2_ESC) {
      Serial.print("[ESC]");
    } else if (c == PS2_PAGEDOWN) {
      Serial.print("[PgDn]");
    } else if (c == PS2_PAGEUP) {
      Serial.print("[PgUp]");
    } else if (c == PS2_LEFTARROW) {
      Serial.print("[Left]");
    } else if (c == PS2_RIGHTARROW) {
      Serial.print("[Right]");
    } else if (c == PS2_UPARROW) {
      Serial.print("[Up]");
    } else if (c == PS2_DOWNARROW) {
      Serial.print("[Down]");
    } else if (c == PS2_DELETE) {
      Serial.print("[Del]");
    } else {
   
      // otherwise, just print all normal characters
      Serial.print(c);
    }
  }
}


Monday, September 23, 2013

Interrupts, the easy way

Many folks starting out in microcontrollers do not know what interrupts are, or are intimidated by them. Today I hope to shed some light on this easy to use, and useful function.

There are two ways to detect if an event has happened, polling, and interrupts. If you are expecting someone to come to your front door, you can get up every few minutes to look out the window (polling), or you can be busy cleaning your house until the doorbell rings (interrupts).

The most common for beginners is polling. In a loop, I check to see if an input is high, or low. Two disadvantages of this method are 1) I might miss an event if I'm busy doing something else, 2) I'm busy checking for the event, and that slows down my other processes.

Interrupts allow me to process a lot of other stuff, and then the interrupt will notify me when the event being monitored happens.

Let's look at a scenario:

I have a push button (doorbell) connected to D2. I have a LED connected to D13. I want to know when someone is at the door, and light the LED when the button is pushed. The polling method would look like this:

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);    
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT_PULLUP);  
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is LOW:
  if (buttonState == LOW) {  
    // turn LED on:  
    digitalWrite(ledPin, HIGH);
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

Now, let's look at the interrupt version of this sketch, Since the event is short lived, we will toggle the state of the LED each time it's pushed (straying from our doorbell example), this would be ideal for monitoring rpm or other fast moving events, by counting the number of triggers per unit of time:

/*
  Button

 Turns on and off a light emitting diode(LED) connected to digital
 pin 13, when pressing a pushbutton attached to pin 2.


 The circuit:
 * LED attached from pin 13 to ground
 * pushbutton attached to pin 2 from Gnd
we are using pinMode INPUT_PULLUP, so no pull up or pull down resistor needed.
INPUT_PULLUP is the same as adding an external pullup resistor


 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13. We are using the onboard LED for our example.
If you use an external on any other pin, you will need a resistor.


 */

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int ledState = HIGH;            // the current state of the output pin
int buttonState = 0;              // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);  
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT_PULLUP);
  // set up the interrupt on pin 2, call the routine,
  // and set the action that triggers the call
  attachInterrupt(0, blink, FALLING);
  // set initial LED state
  digitalWrite(ledPin, ledState);
}

void loop()
{
 digitalWrite(ledPin, buttonState);
}

void blink()
{
  buttonState = !buttonState;
}

Now, we notice that effect is erratic. sometimes the button blinks, sometimes it stays steady. This is due to button bounce. The contacts don't make a single state change, they connect / disconnect quite a few times aver a very short time. We need to debounce the button.

change the void blink() function to the following:

void blink(){
if (reading != lastButtonState){
//reset bounce timer
lastDebounceTime = millis();
}
if ((Millis() - lastDebounceTime) > debounceDelay) {
// if the button state has changed
if (reading != buttonState){
buttonState  = reading;
if (buttonState == HIGH){
ledState = !ledState;
}
}
}
}
and change the loop code to:

//set the led
digitalWrite(ledPin, ledState);
//save the reading, 
//next time through the loop,
// it will be the lastButtonState:
lastButtonState = reading;


and add the following above the setup part of the sketch:

long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // debounce time, increase if output flickers

Follow for more info on Interrupts and INPUT_PULLUP.



Tuesday, September 10, 2013

DHT-11 Temperature and Humidity Sensor

This is the fourth tutorial in our 37 in 1 Sensor Kit series. We have addressed this module and it's family in several previous posts. It's a low end temperature and humidity sensor accurate enough for residential weather and environmental monitoring. It's very easy to use, and hookup info and code samples for both the DHT-11 (included in the sensor kit) and it's bigger brother the DHT-21/22 can be found at

http://arduinotronics.blogspot.com/2013/01/temperature-and-humidity-redux.html

http://www.instructables.com/id/The-Embedded-Arduino-building-an-Arduino-into-a-p/

http://www.instructables.com/id/Temperature-and-Humidity-on-a-Graphical-LCD/



Sensor Kit (or get the DHT-11 by itself)
Male to Female Jumper Kit

Monday, September 9, 2013

Using a Rotary Encoder with the Arduino

This is the third tutorial in our 37 in 1 Sensor Kit series. Normal volume controls and potentiometers have stops at each end of the scale. A rotary encoder is a bit different. There are no stops, it's continuous 360 degree motion, and sends a signal to the controller for each "step" (you can feel the notches or detents). This works well for dialing in a temperature, speed, volume, or even making menu choices. This sketch will output a digit for each stop, so you only need to make that digit value (2,3,4, etc) equal something in your sketch. For instance, set 140 on the encoder to keep a water heater at the correct temperature, or dial in 3600 to set a motor speed. Pushing down on the shaft is a reset button that resets the encoder value to zero. Rotating the shaft clockwise increments the index by one per step, rotating counter clockwise decrements the index. There are 20 steps in one full revolution, and this sketch can count over 65000 steps before starting from zero again. Because this sketch uses interrupts instead of a loop, it responds quickly and there's no missed pulses.

Sensor Kit (or get the rotary encoder by itself)
Male to Female Jumper Kit



/* interrupt routine for Rotary Encoders


   The average rotary encoder has three pins, seen from front: A C B
   Clockwise rotation A(on)->B(on)->A(off)->B(off)
   CounterCW rotation B(on)->A(on)->B(off)->A(off)

   and may be a push switch with another two pins, pulled low at pin 8 in this case
  

*/

// usually the rotary encoders three pins have the ground pin in the middle
enum PinAssignments {
  encoderPinA = 2,   // right (labeled DT on our decoder, yellow wire)
  encoderPinB = 3,   // left (labeled CLK on our decoder, green wire)
  clearButton = 8    // switch (labeled SW on our decoder, orange wire)
// connect the +5v and gnd appropriately
};

volatile unsigned int encoderPos = 0;  // a counter for the dial
unsigned int lastReportedPos = 1;   // change management
static boolean rotating=false;      // debounce management

// interrupt service routine vars
boolean A_set = false;              
boolean B_set = false;


void setup() {

  pinMode(encoderPinA, INPUT_PULLUP); // new method of enabling pullups
  pinMode(encoderPinB, INPUT_PULLUP); 
  pinMode(clearButton, INPUT_PULLUP);
 // turn on pullup resistors (old method)
  //digitalWrite(encoderPinA, HIGH);
 // digitalWrite(encoderPinB, HIGH);
 // digitalWrite(clearButton, HIGH);

// encoder pin on interrupt 0 (pin 2)
  attachInterrupt(0, doEncoderA, CHANGE);
// encoder pin on interrupt 1 (pin 3)
  attachInterrupt(1, doEncoderB, CHANGE);

  Serial.begin(9600);  // output
}

// main loop, work is done by interrupt service routines, this one only prints stuff
void loop() { 
  rotating = true;  // reset the debouncer

  if (lastReportedPos != encoderPos) {
    Serial.print("Index:");
    Serial.println(encoderPos, DEC);
    lastReportedPos = encoderPos;
  }
  if (digitalRead(clearButton) == LOW )  {
    encoderPos = 0;
  }
}

// Interrupt on A changing state
void doEncoderA(){
  // debounce
  if ( rotating ) delay (1);  // wait a little until the bouncing is done

  // Test transition, did things really change? 
  if( digitalRead(encoderPinA) != A_set ) {  // debounce once more
    A_set = !A_set;

    // adjust counter + if A leads B
    if ( A_set && !B_set ) 
      encoderPos += 1;

    rotating = false;  // no more debouncing until loop() hits again
  }
}

// Interrupt on B changing state, same as A above
void doEncoderB(){
  if ( rotating ) delay (1);
  if( digitalRead(encoderPinB) != B_set ) {
    B_set = !B_set;
    //  adjust counter - 1 if B leads A
    if( B_set && !A_set ) 
      encoderPos -= 1;

    rotating = false;
  }
}

Sunday, September 8, 2013

Building a IR Fire Sensor

This second sensor project uses the IR Fire Sensor. It has two outputs, 1 digital, 1 analog. I'm using the digital output (sensitivity set with onboard trimmer pot) to set the Pin 13 LED, to show flicker. I'm dumping the raw analog output to the serial monitor. Increased IR levels decrease the values output to the serial monitor.

Sensor Kit
Male to Female Jumper Kit






const int analogPin =  A0;      // the number of the analog pin
const int digitalPin = 7;     // the number of the digital pin
const int ledPin =  13;      // the number of the LED pin
int aVal = 0;
int dVal = 0;

void setup() {

  Serial.begin(9600);          //  setup serial

  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);    
  // initialize the digital pin as an input:
  pinMode(digitalPin, INPUT);  
}

void loop(){


  aVal = analogRead(analogPin);    // read the input pin
  Serial.println(aVal);             // analog value

  dVal = digitalRead(digitalPin);   // read the input pin
  digitalWrite(ledPin, dVal);    // sets the LED to the digital sensor's value
}

Interfacing a Joystick to an Arduino

We recently received a kit of sensors, and have started documenting how to use them. The sensor we are working with today is a joystick. This is a 2-axis unit with a push button on the shaft. There are two analog outputs, and one digital for the switch. At rest, the unit reads 512x512, with a 1 on the switch. The joystick can be pushed in all directions, with 0x1023, 0x512, 0x0, 512x0, 1023x512, 1023x1023, and 512x1023 at the extremes. Make sure you have your serial monitor speed set correctly. Please suggest practical projects based on this sensor, and we may build it!


Sensor Kit
Male to Female Jumper Kit


// Arduino pin numbers
const int SW_pin = 2; // digital pin connected to switch output
const int X_pin = 0; // analog pin connected to X output
const int Y_pin = 1; // analog pin connected to Y output

void setup() {
  pinMode(SW_pin, INPUT);
  digitalWrite(SW_pin, HIGH);
  Serial.begin(115200);
}

void loop() {
  Serial.print(digitalRead(SW_pin));
  Serial.print(" @ ");
  Serial.print(analogRead(X_pin));
  Serial.print("x");
  Serial.println(analogRead(Y_pin));
  delay(10);
}

Saturday, August 31, 2013

Arduino Keyboard Shield - Part 1

This is the beginning of a multi part series on interfacing a PC keyboard to an Arduino. PS/2 keyboards are ideal, but many USB keyboards provide a PS/2 compatible scan code, so we will address support for those as well.

This first section will address the hardware needed. Subsequent posts will address the software and communications, and eventually a couple of end use projects, including a Ham Radio Teletype.

The approach we are taking is somewhat unique. The sketch needed to decode the keyboard scan codes and convert them into readable characters is somewhat memory intensive, and would not leave a lot of room for a project sketch.  Our solution is embedding a barebones Arduino on the shield, just to do that conversion, and present the host Arduino with character strings over serial.

Parts List:

PS/2 Keyboard
PS/2 Jack
PS/2 Breakout
Headers (to mount breakout to protoshield)
Proto Shield
Barebones Arduino Kit

You will program this shield from your Arduino, so no extra programming cable or headers will be needed at this time, nor will a power supply be needed, as it gets it's power from the host Arduino. Stay tuned for the next part in the series.






Friday, August 16, 2013

Pro Arduino by Apress

Every once in a while, a item comes along that shakes up the normal flow of information or product development. Well, it's happened again. This time, it's a book. Ah, but not any book, it's another Arduino book. "But there are so many Arduino books already", you say. True, but not like this one.

Pro Arduino delves into Social Coding and version control, where collaboration among many developers and contributors is easily managed, version control and patches are tracked, and then it gets into the many ways multiple Arduino's can communicate and share data, much like many  developers can work together on a project. The in's and out's of the new Arduino code changes, Xbee's, Android interaction, simulating sensors, game development, and creation of libraries are all exposed and detailed, with the essentials laid bare for even the beginners enjoyment and edification.

Best of all, you can read it for free at http://www.wowebook.info/book/pro-arduino/ or purchase the paper copy at Amazon!

Thursday, August 8, 2013

37 Sensors, a lifetime of fun

Here is the 37 sensor pack we are picking up this weekend. Not all devices in this pack are sensors, some are indicators of various types, like LED's and Buzzers. Modules include vibration sensors, reed switches, hall effect sensors, IR, rotary encoder, temperature, humidity and many more. There's enough stuff in this kit for thousands of different projects and experimentations. I will be posting projects and tutorials for these sensors over the next few months, so get a kit, and work along with us.

You will want a male to female jumper kit to connect these sensors and actuators to the Arduino!

Thursday, July 25, 2013

DIY CNC / 3D Printer Safety Concerns

The folks at RS Components asked me to post this public service infographic, regarding safe design techniques. Good info when building things that have the ability to burn or main.




Sunday, July 14, 2013

SainSmart 1.8 LCD / DHT-22 Temp / Humidity

I now have a DHT-22 Temperature and humidity module matched up with the SainSmart 1.8 TFT LCD. The tricky part of this project was converting floats to strings for the display. If you don't need decimal point precision, you may not need this function, but it's in there.

UPDATE: Added our SpeakEasy Text-To-Speech Shield, for voice output of the data, and relay activation for HVAC equipment.

Code & Project on Instructables.com at http://www.instructables.com/id/Temperature-and-Humidity-on-a-Graphical-LCD/

The DHT-22 connections and the SainSmart LCD connections are in the code.










Saturday, July 13, 2013

Introducing the SainSmart 1.8 SPI LCD

The SainSmart 1.8 SPI LCD module is a great little display. It uses 5 I/O pins (4 if using the Arduino Reset). It displays clear graphics and text, and has a microsd slot on the back.

I connected the display as follows:

Display - Arduino

VCC - 5v
Gnd - Gnd
SCL - pin 13
SDA - pin 11
RS/DC - Pin 9
Reset - Pin 8
CS - pin 10

The zip file available from download from their site has an pre-1.0 library. I had to change WProgram.h to Arduino.h in ST7735.h to get the samples to compile.

We will be using this display shortly to show temperature, humidity, and barometric pressure, and log the data to a microsd card.

Introducing the SainSmart Uno

I received a box of goodies in UPS this week from SainSmart. I'll be introducing each item I recieved, working up an example, and then mixing them up into fun and interesting projects. The first item I'd like to introduce is the SainSmart Uno.

This $16 Arduino R3 Uno clone is unique in that not only does it have the typical Uno shield headers, but it also has GVS 3 pin headers for each I/O pin.

I plugged it into my USB port, and with no fuss, it installed itself as a Uno on Com7. Now on to the first project!


Saturday, June 15, 2013

Volt Meter & Temperature Monitor - Part 3

Well, not really a improvement over part 2, but now the whole instructable is listed complete on Instructables at http://www.instructables.com/id/Digital-Arduino-Voltmeter-with-Temperature/.

I go more into details on design decisions, errors that came up during the process, etc. Please vote for the project when the vote button appears. It's been submitted to the Arduino contest, and may take some time to be accepted, so please check back. Improvements made as we use this device will be added to the Instructable.

Friday, June 14, 2013

Volt Meter & Temperature Monitor - Part 2

I was unhappy with the previous version of this project, which used a TMP36 analog temperature sensor. The output moved around alot, up to 5 degrees, and wouldn't stabilize. I replaced it with my favorite, the DS18B20 digital sensor. Now I have rock solid temperature readings, rock solid voltage measurement, and everyone is happy.

Since my waterproof DS18B20 is already wired, I wanted to keep the leads together, so I wrote a LOW to D2 to make it the Gnd, and a HIGH to D6 to make it +5vdc to power the DS18B20. A 4.7k resistor goes between data (D3) and +5vdc (D6).

This version measure 0-29vac. To measure DC, remove bridge rectifier and capacitor.


See the changes below:



#include "OneWire.h"
#include "DallasTemperature.h"
#include "LiquidCrystal.h"
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x27, 0xB0, 0xBD, 0x04, 0x00, 0x00, 0xF0 };

int tempNegPin = 2; // Gnd for DS18B20
int tempPosPin = 6;  // +5vdc for DS18B20

int voltPin = 0;     // voltage divider (middle terminal) connected to analog pin 0
                       // outside leads to 0-29vac
int val = 0;           // variable to store the value read
int volt = 0;           // variable to store the voltage calculated


void setup(void)
{
  // Used two unused digital ports as +5v and Gnd for the DS18B20
  pinMode(tempPosPin, OUTPUT);      // sets the digital pin as output
  pinMode(tempNegPin, OUTPUT);      // sets the digital pin as output
  digitalWrite(tempPosPin, HIGH);       // sets digital pin to +5vdc
  digitalWrite(tempNegPin, LOW);     // sets digital pin to Gnd

  lcd.begin(20, 4);            // setup LCD

  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(insideThermometer, 10);

}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    lcd.setCursor(0, 2);
    lcd.print("Error getting");
    lcd.setCursor(0, 3);
    lcd.print("temperature");

  } else {
    lcd.setCursor(0, 2);
    lcd.print("Temp ");
    lcd.print((char)223);
    lcd.print("C: ");
    lcd.print(tempC);
    lcd.setCursor(0, 3);
    lcd.print("Temp ");
    lcd.print((char)223);
    lcd.print("F: ");
    lcd.print(DallasTemperature::toFahrenheit(tempC));

  }
}

void loop(void)
{
  delay(500);

   val = analogRead(voltPin);    // read the input pin

   volt = map(val, 0, 1023, 0, 29); // map 29v range

   lcd.setCursor(0, 0);
   lcd.print("VAC  ");
   if (volt<10) lcd.print=(" ");
   lcd.print(volt);

  sensors.requestTemperatures();

  printTemperature(insideThermometer);

}







Thursday, June 13, 2013

Arduino Sous Vide

Sous Vide cooking is the art of low temperature cooking in water, where the food is protected by a plastic bag. You don't overheat the food, and it keeps all the juices and flavors in, preventing the food from drying out. A Arduino and a crockpot are an ideal combination for making this work, but you could also use a rice cooker if you have one available. Here is one of our favorite tutorials for this method.

http://learn.adafruit.com/sous-vide-powered-by-arduino-the-sous-viduino/sous-vide

We will be showing our crockpot version shortly.