Show Posts
Pages: [1] 2
1  Using Arduino / Motors, Mechanics, and Power / Re: Pin out resistor on: June 18, 2014, 09:22:21 pm
Always use a 1K in the base, with 5V this gives you a base current of 5mA.  You can go lower on the base resistor, but don't exceed 20ma.

Use an external power supply, without knowing all the details, it appears you're connected power is USB only and the port is limiting current to your circuit.

...I hope this helps!!!
2  Using Arduino / LEDs and Multiplexing / Re: Simple Bicolor LED too dim - Arduino Uno on: June 18, 2014, 08:59:02 pm
Pins default to INPUT, therefore high-impedance, which would make the LED dimmer if they're not declared as an OUTPUT.
3  General Category / General Discussion / Littlebits, a lesson in magnetism or electronics? on: June 18, 2014, 08:50:16 pm
I was just introduced to littlebits via an email on the Arduino forum.  I just don't get it?  for anyone 8+ years of age; I'd rather get 50 cents worth of leds and teach polarity, resistance, regulation and such ( over-current and burn out a few in the teaching process).  ...not magnets.  I think these "bits" dumb down the electronics aspect of what's being built.  ...maybe it will fuel its users beyond the magnets and hopefully they'll understand what's really happening and they realize the magnets are only a conductor.

If you gave a littlebit user a 1K resistor, an LED, and a 9v battery, would they ask "where are the magnets"?

...just my thoughts on the "bits"
4  Using Arduino / Networking, Protocols, and Devices / Re: new library UIPEthernet: uIP adapted to Arduino for ENC28J60 on: June 18, 2014, 06:03:03 pm

I stopped by the forum to say thanks for the lib. I got my first ENC28J60 last week; I haven't had any problems so far and I've tried many programs to I'm coding my own and learning as very little jquery as I need to :-)

There really hasn't been anything I've come across that doesn't work.  The tip to to disable UDP and tweak the number of connections in /utility/uipethernet-conf.h has resolved any issues I've had.

..thanks again! -Dan
5  Using Arduino / General Electronics / Re: Trying to make a mic preamp on: October 04, 2013, 07:04:37 pm
Measure the resistance of the mic leads between the white (audio out) and red wire (pos).  Put the multimeter in 20k range.  What's the value?  The mic might be internally, what is called "biased" already.  If this is the case, the 5v resistor may not be needed.

This is a great resource for mics.

...don't give up on this project, you'll get it going!  Plenty of ppl to help.
6  Using Arduino / General Electronics / Re: Trying to make a mic preamp on: October 02, 2013, 06:41:32 pm
Yes, the LM386 will work fine, start off with that.

The LM386 has one amp, most with 8 pins have 2 amps.  Take a look here, you'll see that pins are different between single and dual.

Without getting too much into opamps, most circuits that require them, you can use any package you like, just note the pin differences for this mic preamp example.

"These give half of VCC at zero SPL:"  Arduino at 5 volts, no sound will be 2.5v (or AnalogRead ~511).

The 3-wire mic shouldn't be any different.  VCC, GND, AUD out through 10uf Cap.

Stick with the DIY, you'll learn more.  Don't buy one of those premade sensors, they only give you an ON/OFF via a comparator based on a threshold you set.

7  Using Arduino / General Electronics / Re: Trying to make a mic preamp on: October 02, 2013, 05:22:32 pm
I've had really good results with these single stage preamps, the quality of the opamp/mic make a difference.  Use a socket for opamp so you can try different ones that are pin compatible.

I usually use dual opamp, as there are many more of these.  Careful though, pins are different on single and dual opamps.

These give half of VCC at zero SPL:

8  Using Arduino / Storage / Re: LC Studio Card Reader - BAD PCB on: October 02, 2013, 04:41:49 pm
I have an LC Studio labeled reader that works fine with 5v and 3.3v.  The first post mentioned "noise" and that the caps for the regulator were not grounded.  C3(input and other side to ground) C4(output and other side to ground).  My LC Studio has proper connections, proper grounds and I don't have issues.

Check the LM1117 regulator datasheet pinouts: mine is (1 Gnd, 2-Vout, 3-Vin).  You might have shorted the supply to ground as the schematic pins are not left to right with the datasheet.  Always check datasheet, and test with dmm if you can.

If you're using sdfat check the "troubleshooting.txt" in the lib directory.  Your card could be an issue as well.  Try others if you have them.  Sometimes it's hit or miss with the cards.  I haven't used anything >4gb.
Also, I find you must use SPI_HALF_SPEED with these adapters.

Posting code might help too.

9  Using Arduino / Storage / Re: This example doesn't work on: September 26, 2013, 10:22:15 am
I had similar issues with some of my older programs when I upgraded the library to "sdfatlib20130629".

Those functions have changed in the new library.  The new functions return boolean.  Check the new docs located in library directory under "html".

this link might help too.

Maybe this will help.  **Warning** Compiles, but untested.

    Basic example reading and writing to the microSD shield
 Based on the SdFat Library by Bill Greiman
 SparkFun Electronics
 This example creates a file (or opens it if the file already exists) named 'Test.txt.'
 A string with the value 'Millis: (number of millis)' is appended to the end of the file.
 After writing to the file, the contents of the entire file are printed to the serial port.

//Add the SdFat Libraries
#include <SdFat.h>
#include <SdFatUtil.h>
#include <ctype.h>

//Create the variables to be used by SdFat Library
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;

#define SD_CHIP_SELECT  10 // Your select pin (4 on ethernet shield)

char name[] = "Test.txt";     //Create an array that contains the name of our file.
char contents[256];           //This will be a data buffer for writing contents to the file.
char in_char=0;
int index=0;                  //Index will keep track of our position within the contents buffer.

void setup(void)
  Serial.begin(9600);        //Start a serial connection.
  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  if (!card.init(SPI_HALF_SPEED, SD_CHIP_SELECT)) Serial.println("card.init failed!");
  // initialize a FAT volume
  if (!volume.init(&card)) Serial.println("vol.init failed!");
  //Initialize a volume on the SD card.
  if (!root.openRoot(&volume)) Serial.println("openRoot failed");
  //volume.init(card);         //Initialize a volume on the SD card.
  //root.openRoot(volume);     //Open the root directory in the volume.
void loop(void){, name, O_CREAT | O_APPEND | O_WRITE);    //Open or create the file 'name' in 'root' for writing to the end of the file.
  sprintf(contents, "Millis: %d    ", millis());    //Copy the letters 'Millis: ' followed by the integer value of the millis() function into the 'contents' array.
  file.print(contents);    //Write the 'contents' array to the end of the file.
  file.close();            //Close the file., name, O_READ);    //Open the file in read mode.;              //Get the first byte in the file.
  //Keep reading characters from the file until we get an error or reach the end of the file. (This will output the entire contents of the file).
  while(in_char >=0){            //If the value of the character is less than 0 we've reached the end of the file.
    Serial.print(in_char);    //Print the current character;      //Get the next character
  file.close();    //Close the file
  delay(1000);     //Wait 1 second before repeating the process.
10  Using Arduino / Programming Questions / Re: Shifting 2D Array - 8x8 RGB on: August 15, 2013, 08:10:50 pm
I've invited the author of the nice lib to join the discussion.  Without this lib, the demo code provided by iteadstudio leaves nothing to be desired.

Kudos to lincomatic and his instructables post:
11  Using Arduino / Programming Questions / Re: Shifting 2D Array - 8x8 RGB on: August 15, 2013, 07:36:04 pm
I experimented with the memcpy function and it seems to work very well.

byte display_byte[3][64];   // display array - 64 bytes x 3 colours
byte buffer_byte[3][64];    // buffer copy test

void mem() {
  memcpy(buffer_byte, display_byte, sizeof(buffer_byte));  // Copies Buffer display_byte to buffer_byte

I tried changing the 2D array to 3D, no luck.  Trying to shift every 8th byte in one direction or another would be a nightmare. In looking at the i2c slave code, the slave sets x,y coordinates based on incoming data (64 bytes for each color). i.e.

   if (c == 0){
      for (byte x = 0; x < 8; x++){
        for (byte y = 0; y < 8; y++){
           PixelRGB *p = Colorduino.GetPixel(x,y);  // my comment: Get.Pixel, actually "sets pixel" for writing in the offscreen framebuffer
           p->r =;

  //1 pixel = 3 bytes B00000000 B00000000 B00000000.
  //We send R then G then B bytes as 3 separate transfers
  //This is because if we make the I2C buffer too large, we run out of SRAM for other things on our master Arduino
  if (Wire.available()>66) { //when buffer full, process data. 66 =  start byte + colour + 64 pixel data + end byte
    // error check - make sure our data starts with the right byte  
    if ( != START_OF_DATA) {
      //else handle error by reading remaining data until end of data marker (if available)
      while (Wire.available()>0 &&!=END_OF_DATA) {}      

    byte c =; //read our color byte so we know if these are the R, G or B pixels.
    //depeding on c read pixels in as R G or B
    //read red display data
    if (c == 0){
      for (byte x = 0; x < 8; x++){
        for (byte y = 0; y < 8; y++){
           PixelRGB *p = Colorduino.GetPixel(x,y);
           p->r =;
    //read green display data
    if (c == 1){
      for (byte x = 0; x < 8; x++){
        for (byte y = 0; y < 8; y++){
          PixelRGB *p = Colorduino.GetPixel(x,y);
           p->g =;
    //read blue display data
    if (c == 2){
      for (byte x = 0; x < 8; x++){
        for (byte y = 0; y < 8; y++){
           PixelRGB *p = Colorduino.GetPixel(x,y);
           p->b =;
    //read end of data marker
    if ( {
      //if colour is blue, then update display
      if (c == 2){Colorduino.FlipPage();}

I'm thinking I could have the slave do the work in shifting pixels by adding additional i2c commands:

the following functions exist in the lib:

 void FlipPage() {  // my comment: offscreen to active framebuffer
    // swap frame buffers
    PixelRGB *tmp = curDrawFrame;
    curDrawFrame = curWriteFrame;
    curWriteFrame = tmp;

  // get a pixel for writing in the offscreen framebuffer
  PixelRGB *GetPixel(unsigned char x,unsigned char y) {
    return curWriteFrame + (y * ColorduinoScreenWidth) + x;

  // get a pixel from the active framebuffer
  PixelRGB *GetDrawPixel(unsigned char x,unsigned char y) {
    return curDrawFrame + (y * ColorduinoScreenWidth) + x;

  // set a pixel in the offscreen frame buffer
  void SetPixel(unsigned char x, unsigned char y, unsigned char r, unsigned char g, unsigned char b)
    PixelRGB *p = GetPixel(x,y);
    p->r = r;
    p->g = g;
    p->b = b;

Thanks again for your time.

12  Using Arduino / Programming Questions / Re: Help with Serial.print on: August 14, 2013, 09:56:16 pm
What does "nothing prints" mean?

...are you getting ?


    Serial.print("level "),
    Serial.print("  min  "),
    Serial.print{"  max  "),

...if the values don't get populated, make them global.  I have no problem declaring a variable inside a function and then Serial.print"ing" it within that function.

I dunno.
13  Using Arduino / Programming Questions / Re: Shifting 2D Array - 8x8 RGB on: August 14, 2013, 09:05:52 pm
Thanks for the reply.

Pixels shifted should be completely discarded (turned black) scrolling text or animations that leave view.

I do have enough room to copy the buffer.  I checked it with:

int freeRam () {
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);

...I have 1157 free (328 chip)

I'm hoping just to manipulate the current buffer, but adding another could be of other use too.

I just want to fill the shifted buffer (or copy) with black:

byte display_byte[0][pixelnum]  // red   (0,pixelnum)
byte display_byte[1][pixelnum]  // grn   (0,pixelnum)
byte display_byte[2][pixelnum]  // blu   (0,pixelnum)

Breaking the 64 pixels into rows and columns does help.

In the library, this function: ...converts the x,y coordinates to pixels nums.

//update display buffer using x,y,r,g,b format
void display(byte x, byte y, byte r, byte g, byte b) {
  byte p = (y*8)+x;   //convert from x,y to pixel number in array
  display_byte[0][p] = r;
  display_byte[1][p] = g;
  display_byte[2][p] = b;


14  Using Arduino / Programming Questions / Shifting 2D Array - 8x8 RGB on: August 14, 2013, 06:17:04 pm
Greetings forum,

I hope someone could help me out in shifting a 2D array.  I recently bought a Colorduino and I have coded many cool patterns and animations.  However, I found the need to shift the buffer to create better animations and make the code more streamlined.

I'd like to shiftup, shiftdown, shiftleft, and shiftright.  The Colorduino is an 8x8 RGB matrix.

The display buffer looks like this:

byte display_byte[3][64];   //display array - 64 bytes x 3 colours.  0 red, 1 grn, 2 blu    64 pixels

I'd like to shift the display and then call directly:

//send display buffer to display via i2c
void update_display(byte addr) {   
  BlinkM_sendBuffer(addr, 0, display_byte[0]);   
  BlinkM_sendBuffer(addr, 1, display_byte[1]);   
  BlinkM_sendBuffer(addr, 2, display_byte[2]); 

I'd like to create functions like this, where n is num of shifts:
void shiftRight(int n) {


I've tried some code here, but nothing meaningful to post:

99% of the time I've found answers to all my C++ and Arduino questions on the net.

Thanks for your time.

15  Topics / Home Automation and Networked Objects / X10 - CM11a Receive/Monitor Powerline Commands on: April 26, 2013, 11:25:33 am

I thought I'd share a Proof of Concept for receiving powerline commands from an X10 CM11a serial interface.  What it does is recieve commands via CM11a <> TTL shifter <> software serial and print commands to Arduino hardware serial.

This could be modified to control or display commands with your arduino.  The CM11a is an RS232 device and there's no need for the "zero-crossing" based PSC05/TW523 module.

You MUST use a ttl level shifter, do NOT connect an RS232 device directly to your arduino.

I hope someone likes this, I could not find any other code to receive commands with CM11a.  I'm a hobbyist; the code is what it is.  I hope this might inspire someone to make it better.

Thanks,  Dan G.

- Arduino folks, of course!
- "LJRob" for the initial sketch for sending commands via CM11a
- BroHogan - Parse code at

Arduino IDE 1.0.3


Proof of Concept: CM11a Powerline Command Monitor
Author: Dan G.

Recieve commands via CM11a <> TTL shifter <>
software serial and print commands to Arduino hardware serial.

Since the PSC05/TW523 modules are no longer made.  CM11a can be used to receive PLC.
They are much cheaper and available.

Do NOT connect CM11a directly to Arduino, you MUST use TTL level shifter.

Search for "cm11a_protocol.txt" for more details.

- Arduino folks, of course!
- "LJRob" for the initial sketch for sending commands via CM11a
- BroHogan - Parse code at

#define ON   B10000000  // Bitshifted ON
#define OFF  B11000000  // Bitshifted OFF

byte lookup[16] = {  // Lookup table for House and Unit Code
  //Binary  House Unit
  B0110,  // A 1
  B1110,  // B 2
  B0010,  // C 3
  B1010,  // D 4
  B0001,  // E 5
  B1001,  // F 6
  B0101,  // G 7
  B1101,  // H 8
  B0111,  // I 9
  B1111,  // J 10
  B0011,  // K 11
  B1011,  // L 12
  B0000,  // M 13
  B1000,  // N 14
  B0100,  // O 15
  B1100,  // P 16

#include <SoftwareSerial.h> // For the TTL to RS232
SoftwareSerial X10Serial(2, 3); // RX, TX to TTL RS232

byte incomingByte; // Controller status
byte Hc;           // Housecode
char chrHc = Hc;   // Housecode to char
byte U;            // Unit
byte Cmd;          // ON or OFF

//Serial buffer
byte serIn; // var that will hold the bytes-in read from the serialBuffer
byte serInString[9]; // CM11a can send up to 10 bytes (program only handles 3 bytes)
int serInIndx = 0; // index of serInString[] in which to insert the next incoming byte
int serOutIndx = 0; // index of the outgoing serInString[] array;

void setup() {

  X10Serial.begin(4800);    // X10 Baud 4800 8,NONE,1
  Serial.println("x10 CM11a Ready:");

void loop(){
  CheckX10controller();  // Check CM11a for data or power failure.

// Read from X10 controller
void CheckX10controller() {

  if (X10Serial.available() > 0) {
    incomingByte =;

    switch (incomingByte) {
      case ((byte)0xA5): // Polling: This happens the first time you plug the X10 controller in the socket or after a power cut
      delay(100);  // CM11a is slow; don't write too fast, won't work!
      X10Serial.write((byte)0x9B); // Acknowledge / Clear, This must be cleared or it will not except any other x10 commands
      Serial.println("Power Supply Restored");

      case ((byte)0x5A): // Polling: When powerline command received, CM11a send this byte.
      delay(100); // CM11a is slow; don't write too fast, won't work!
      X10Serial.write((byte)0xC3);   // Send byte, initiate the data transfer.
      //default:  //Used for testing only
      //ReadData(); //Used for testing only

void ReadData() {

  int sb;
  if(X10Serial.available()) {
    while (X10Serial.available()){
      sb =;
      serInString[serInIndx] = sb;

void parseX10SerialString(){
  if( serInIndx > 0) {
    //debug Serial.print("Bytes Received: ");
    //debug Serial.println(serInString[0]);
    if (serInString[1] == 0) {
      //debug Serial.print("X10 Address 2nd byte is: ");
      //debug Serial.println(serInString[1], HEX);
      //debug Serial.print("HcU in BIN: ");
      //debug Serial.println(serInString[2], BIN);
      Hc = serInString[2] >> 4;  // Gets Housecode binary
      //debug Serial.print("Hc in BIN: ");
      //debug Serial.println(Hc, BIN);
      for (byte i=0; i<16; i++){ // use lookup table for Housecode
        if (lookup[i] == Hc){
          Hc = i+65;   // this gives int House 'A' - 'P'
          char chrHc = Hc;  // Convert int Hc to Char for Serial print
          Serial.print("Housecode: ");
          break;            // stop search when found!
      U = serInString[2] << 4;   // Bitshift for Unit
      U = U >> 4; // Final "bitdance" for Unit
      //debug Serial.print("U in BIN: ");
      //debug Serial.println(U, BIN);
      for (byte i=0; i<16; i++){  // use lookup table for Unit
        if (lookup[i] == U){
          U = i+1;        // this gives Unit 1-16
          Serial.print("Unit: ");
          break;          // stop search when found!
    if (serInString[1] == 1) {
      //debug Serial.print("X10 Function 2nd byte is: ");
      //debug Serial.println(serInString[1], BIN);
      //debug Serial.print("Function: ");
      Cmd = serInString[2] << 6; // Bitshift out redundant Housecode
      Serial.print("Command: ");
      if(Cmd == B10000000)Serial.println("ON ");
      if(Cmd == B11000000)Serial.println("OFF ");
      //debug Serial.print("binary: ");
      //debug Serial.println(Cmd, BIN);
  //reset all the functions to be able to fill the string back with content
  serOutIndx = 0;
  serInIndx = 0;

Pages: [1] 2