Friday 29 January 2016

New Arduino Project

Today there should have been a nice video of a Blackbird enjoying some apple pieces I had put out but on reviewing the footage today I found the camera had focussed on the background instead of the bird.

Long time readers may remember I built a rain gauge around an Arduino Mega with a digital read out. That has proved to be very reliable so I have decoded to expand on its capabilities. This time instead of using a four line LED display which can only be read from a close distance I intend to rebuild the unit using an Arduino Uno this time and the display will be 10mm tall individual seven segment displays. That has meant learning some new coding to access the display. I bought an eight digit seven segment display which has a MAX7219 chip on board which needs only five wires to access it.

Not only will the display show rainfall but also temperature and humidity. The idea being to use four of the LEDs to show temperature and the other four to show the humidity. Also I have ordered a further two digit seven segment display to show the rainfall.

So far I have got as far as uploading a test routine to make sure I can access all the digits and the decimal points. The latter took me longer to understand the instructions I found on the internet. This is a short video of the test display:



For those who may be interested this is the sketch (program) which is uploaded to the Arduino.
It is my modification of one I found on the internet::

//We always have to include the library
#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 ***** These pin numbers are used on my Uno R3 *****
 pin 12 is connected to the DataIn
 pin 11 is connected to the CLK
 pin 10 is connected to LOAD
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(12,11,10,1);

/* wait a bit between updates of the display */
unsigned long delaytime=350;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a low value */
  lc.setIntensity(0,2);
  /* and clear the display */
  lc.clearDisplay(0);
}


/*
 This will display the characters for the
 word "Arduino" one after the other.
 */
void writeArduinoOn7Segment() {
  lc.setChar(0,7,'a',false);
  delay(delaytime);
  lc.setRow(0,6,0x05);
  delay(delaytime);
  lc.setChar(0,5,'d',false);
  delay(delaytime);
  lc.setRow(0,4,0x1c);
  delay(delaytime);
  lc.setRow(0,3,B00010000);
  delay(delaytime);
  lc.setRow(0,2,0x15);
  delay(delaytime);
  lc.setRow(0,1,0x1D);
  delay(delaytime);
 // lc.clearDisplay(0);
  delay(delaytime);
}

/*
  This will scroll all the decimal numbers
  and flash the decimal point on LED 0.
 */
void scrollDigits() {
for(int i=0;i<10 br="" i="">    lc.setDigit(0,0,i,false);
    delay(delaytime);
   lc.setDigit(0,0,i,'dp');
   delay(delaytime);
  }
  delay(delaytime);
  lc.clearDisplay(0);
  delay(delaytime);
}

void loop() {
  writeArduinoOn7Segment();
  delay(delaytime);
  scrollDigits();
 
}

5 comments:

  1. Like poetry! Well not really, although some may find it parses well.

    ReplyDelete
    Replies
    1. Wilma: Stream of conciousness free verse no less.

      Delete
  2. You are much better at this than I am. I was thinking of Arduino as a project for this winter but decided Blender would be cheaper. Maybe next winter.
    I have a bit of software somewhere that pops notes in a different colour and also numbers the script lines. I'll try and find it and let you know where to get it from.

    ReplyDelete
    Replies
    1. Adrian: I think I enjoy playing with the Arduino computers better than the Raspberry Pi. The RPi is more versatile but I find the programming much harder.
      The software you mentioned sounds good. I had real problem getting the code in Blogger. Had to highlight it all and copy / paste. Then Blogger moaned it was faulty HTML but accepted it in the end.

      Delete
    2. Adrian: Thanks for the email contact. I won't publish it here.

      Delete

Thank you for visiting. Hope you enjoyed the pictures. Any comment, or correction to any information or identification I get wrong, is most welcome. John

Related Posts with Thumbnails