Back to Step by Step Course by Robojax

Lesson 24: 74HC595 Two Digit Display | Arduino Step by Step Course

Related or required files and link to this lesson

Part 2: LCD, LED and OLED Screens

In this lecture we learn how to use SD1306 OLED Display to display text and shapes on the screen.


 /* 
 *  updated by Ahmad Shamshiri for Robojax 
  Lesson 24: 2 digits dispaly using 74HC595 chip
 *  On Monday Sep 17, 2019 at 00:03 in Ajax, Ontario, Canada
 *  
 *  Watch video instruction for this video: https://youtu.be/pJPdH7mOUzk
 *  At the moments, it doesn't display dicimal points. It needs a little work to make it work

 * This code is part of Arduino Step by Step Course which starts here:  https://youtu.be/-6qSrDUA5a8
 * 
 * for library of this code visit http://robojax.com/
 * 
If you found this tutorial helpful, please support me so I can continue creating 
content like this. Make a donation using PayPal by credit card https://bit.ly/donate-robojax 


 * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>. 


 *  Original source and text.
 *  2 Digitl 7 segment display PCB board with (2) 74HC595 shift register ICs
 *  Arduino Tutorial - www.Ardumotive.com
 *  Dev: Michalis Vasilakis // Date: 31/1/2018 // Ver:1.0
 */
#include <ShiftRegister74HC595.h>
#define SDI 7
#define SCLK 6
#define LOAD 5
#define DIGITS 2
// create shift register object (number of shift registers, data pin, clock pin, latch pin)
ShiftRegister74HC595 sr (DIGITS, SDI, SCLK, LOAD); 


int value,digit1,digit2,digit3,digit4; 
uint8_t  digits[] = {B11000000, //0
                      B11111001, //1 
                      B10100100, //2
                      B10110000, //3 
                      B10011001, //4
                      B10010010, //5
                      B10000010, //6 
                      B11111000, //7
                      B10000000, //8
                      B10010000 //9
                     };
                        
void setup() {


  
}

void loop() {
  showNumber(18);
  delay(2000);//
  for(int i=0; i<=99; i++)
  {
    showNumber(i);
    delay(100);
  }
  delay(2000);
  for(int i=99; i >=0; i--)
  {
    showNumber(i);
    delay(50);
  }
   delay(2000);   
}// loop





/*
 * @brief shows number on the Seven Segment Display
 * @param "num" is integer
 * @return returns none
 * Usage to show 18: showNumber(18);
 * Written by Ahmad Shamshiri on Sep 17, 2019. 
 * in Ajax, Ontario, Canada
 * www.Robojax.com 
 */
void showNumber(int num)
{
    digit2=num % 10 ;
    digit1=(num / 10) % 10 ;
    //Send them to 7 segment displays
    uint8_t numberToPrint[]= {digits[digit2],digits[digit1]};
    sr.setAll(numberToPrint);  
}



   

The least I expect from you is to give the video a thumbs up and subscribe to my channel. I appreciate it. I have spent hundreds of hours making these lectures and writing code. You don't lose anything by subscribing to my channel. Your subscription is a stamp of approval for my videos, helping more people find them and, in turn, helping me. Thank you!

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal

**** AFFILIATE PROGRAM **** We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Right Side
footer