Things used in this project

Hardware components:
Magconn Magconn Developer Kit
×1
Ard nano
Arduino Arduino Nano R3
×1
USB Li-Po Battery Charger PCBA
×1
Li-Po Battery 900mAh
×1
Software apps and online services:
Ide web
Arduino Arduino IDE

Schematics

Schematics
Schematic dowtg5nte3

Code

Lap counterArduino
const byte numeral[10] = {
  //ABCDEFG dp//
  B11111100,  //0
  B01100000,  //1
  B11011010,  //2
  B11110010,  //3
  B01100110,  //4
  B10110110,  //5
  B00111110,  //6
  B11100000,  //7
  B11111110,  //8
  B11100110,  //9
};

// dp, G, F, E, D, C, B, A
const int segmentPins[8] = { 9,8,7,6,5,4,3,2 };
const int nbrDigits = 2;
const int digitPins[nbrDigits] = { 12,13 };
const int buttonPin = 11;
int buttonState;             // the current reading from the input pin
int lastButtonState = HIGH;   // the previous reading from the input pin
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers
int value = -1;



void setup() 
{
  for(int i=0; i<8; i++)
  {
    pinMode(segmentPins[i], OUTPUT);    
  }
  for(int i=0; i<nbrDigits; i++)
  {
    pinMode(digitPins[i], OUTPUT);  
    digitalWrite(digitPins[i], 1);   
  }
  pinMode(buttonPin, INPUT);
  digitalWrite(buttonPin, HIGH);   //   
}



void loop() 
{
  int reading = digitalRead(buttonPin);
  if (reading != lastButtonState) { // reset the debouncing timer
    lastDebounceTime = millis();
  }
  if ((millis() - lastDebounceTime) > debounceDelay) {
    if (reading != buttonState) {
      buttonState = reading;

      if (buttonState == HIGH) {
        value = value + 1;
      }
    }
  }
  lastButtonState = reading;  
  showNumber(value);
}



void showNumber(int number)
{
  if(number == 0)
    showDigit(0, nbrDigits-1);
    else
    {
      for(int digit = nbrDigits-1; digit>=0; digit--)
      {
        if (number>0)
        {
          showDigit(number%10, digit);
          number = number/10;
        }
      }
    }
}



void  showDigit(int number, int digit)
{
  //boolean   isBitSet;  
  digitalWrite(digitPins[digit],0);  //1
  for (int segment = 1; segment <8 ; segment++) //segment A ~ dp  
  {
    boolean isBitSet = bitRead(numeral[number], segment);   //byte numeral[number] segment  
    digitalWrite(segmentPins[segment], isBitSet);
    }
    //isBitSet = !isBitSet
    delay(5);
    digitalWrite(digitPins[digit], 1);
  }
  

Credits

20151117 142936 gupweolrle
Oscar Seo

I am a H / W engineer and manager at Magconn Inc. Try the "magconn connector" for connectivity convenience.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Water Softener
Easy
  • 292
  • 5

Full instructions

Sweeping frequency magnetic hard water conditioner

Know the Temp of Your Home From Anywhere with Arduino Cloud!
Easy
  • 1,312
  • 9

Full instructions

Ever wanted to know the temperature of your home from somewhere? Here's an easy way to do it with Arduino Cloud and the Yun Shield!

Simple Obstacle Senor With Arduino
Easy
  • 88
  • 2

Full instructions

I am gonna show you how to make a simple obstacle sensing system with cheap parts like IR LED and photo diode.

Safe City: A Device to Keep You Safe
Easy
  • 669
  • 6

Full instructions

The device will keep you safe. Just have to click a button and your precise location will be shared.

Arduino UNO Home Automation using Bluetooth HC05 module
Easy
  • 15
  • 1

Protip

Home Automation Attributes: Turning ON/OFF light bulb (AC 220V). Automatically Turning the Led ON/OFF depending on light intensity.

Connect Your Thinxtra Xkit Using Sigfox
Easy
  • 131
  • 2

Protip

Learn how to build an IoT application over Sigfox integrated with Ubidots - send temp readings based on motion sensors.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog