Some new stuff
  1. Arduino Park Control
  2. Arduino USB2serial programming the bare bone
  3. Arduino Projects Videos added
  4. Arduino Xbee projects
  5. Arduino dB Meter 
  6. Trying to get the IOIO going. 
  7. IOIO is going....bluetooth
  8. Attiny 2313 bluetooth bee RC car
  9. Compass and temperature added
  10. AVR programmer
  11. USB2Serial and Ethernet POE
  12. Arduino LPG Sensor
  13. Program the Arduino Mini 05
  14. Lipo Rider Pro in action
  15. EZ Robot Builder kit arrived 10 Nov 2012
  16. Arduino VA Meter!
  17. 05 Nov 2012 Project Sentry Gun.
  18. Attiny85 PIR Sensor 10 Dec 2012 
  19. 0-30VDC3A and 2-28VDC10A bench PSU's
  20. 19 Dec 2012 Arduino Voltmeter LCD
  21. 29 Dec 2012 Arduino Tachometer&Speedometer LCD
  22. 03 Jan 2013 Arduino AC Phase Control. 
  23. 18 Jan 2013 Arduino Distance Meter
  24. 22 Jan 2013 Arduino Digital Clock and Date
  25. 31 Jan 2013 Arduino Digital Clock and Date 8x2 LCD
  26. Feb 2013 LCD and Backpack
  27. Feb 2013 7 Segment Serial Clock Sparkfun. Distance Sensor with "newping" library
  28. Feb 2013 Lelo Remote
  29. 01/03/2013 Arduino Adafruit 7 Seg Digital Clock with RTC and backpack 
  30. Arduino Frequency Meter 26/03/2013
  31. Another RC  Car controlled by Arduino 06/04/2013
  32. My quadcopter project update 25 April 2013
  33. My Aqua Quad Copter Flying 26 April 2013enlightened
  34. Another monster RC truck;strong one! 11July2013cool
  35. X-Frame Quad Copter 31 July 2013cool
  36. Arduino GSM Sheild added.28/8/2013
  37. 1.8inch TFT screen 13/09/2013cool
  38. 04/11/2014 added PID Soldering Iron Control
  39. Added bluetooth servo control 04/11/2014
  40. ESP8266 first try.16/03/2015
  41. Arduino Uno Quadcopter 19 May 2015
  42. IOT WemosD1 Amp Meter

 

 



24Feb 2013

Arduino 7 segment digital clock with Sparkfun Serial 7 Segment Display.

 

The code is from 11-4-2012 Spark Fun Electronics Nathan Seidle

Serial7Segment is an open source seven segment display. 

 This is example code that shows how to display basic numbers and control the decimal, colon, and AM/PM dot.
 
 Note: This code works with displays the support the center colon and extra dots (AM/PM, not decimals).
 
 Note: This code expects the display to be listening at 9600bps. If your display is not at 9600bps, you can
 do a software or hardware reset. See the Wiki for more info: 
 http://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands#wiki-baud
 
 To get this code to work, attached an Serial7Segment to an Arduino Uno using the following pins:
 Pin 7 on Uno (software serial RX) to TX on Serial7Segment
 Pin 8 on Uno to RX on Serial7Segment
 VIN to PWR
 GND to GND
 
*/

#include

SoftwareSerial Serial7Segment(7, 8); //RX pin, TX pin

int cycles = 0;

//From https://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands#wiki-decimal
#define APOSTROPHE  5
#define COLON       4
#define DECIMAL4    3
#define DECIMAL3    2
#define DECIMAL2    1
#define DECIMAL1    0

long millisTimer;
byte seconds = 0;
byte minutes = 0;
byte hours = 0;
boolean amTime = true;
boolean colonOn = false;

char tempString[100]; //Used for sprintf

void setup() {

  Serial.begin(9600);
  Serial.println("OpenSegment Example Code");

  Serial7Segment.begin(9600); //Talk to the Serial7Segment at 9600 bps
  Serial7Segment.write('v'); //Reset the display - this forces the cursor to return to the beginning of the display

  Serial7Segment.print("0822"); //Send the hour and minutes to the display

  millisTimer = millis();

  //For testing, we initialize the variables to the current time
  seconds = 01;
  minutes = 9;
  hours = 17;
}

void loop() 
{
  //Every second update the various variables and blink colon/apos/decimal
  if( (millis() - millisTimer) > 1000)
  {
    millisTimer += 1000; //Adjust the timer forward 1 second

    seconds++;
    if(seconds > 59)
    {
      seconds -= 60; //Reset seconds and increment minutes
      minutes++;
      if(minutes > 59)
      {
        minutes -= 60; //Reset minutes and increment hours
        hours++;
        if(hours > 12)
        {
          hours -= 12; //Reset hours and flip AM/PM
          if(amTime == true) 
            amTime = false; //Flip AM to PM
          else
            amTime = true;
        }
      }
    }

    //Blink the colon every other second
    if(colonOn == true)
    {
      colonOn = false;
      Serial7Segment.write(0x77);  // Decimal, colon, apostrophe control command
      Serial7Segment.write((byte) 0); // Turns off colon, apostrophoe, and all decimals
    }
    else
    {
      colonOn = true; 
      Serial7Segment.write(0x77);  // Decimal, colon, apostrophe control command
      Serial7Segment.write( (1<     }
  }

  //Debug print the time
  sprintf(tempString, "HH:MM:SS %02d:%02d:%02d", hours, minutes, seconds);
  Serial.println(tempString);

  sprintf(tempString, "%02d%02d", hours, minutes);
  Serial7Segment.print(tempString); //Send serial string out the soft serial port to the S7S

  delay(100);
}

Back Back to top