Subversion Repositories idreammicro-arduino

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 jlesech 1
/**************************************************************************//**
2
 * \brief MAX7219 library for Arduino - Demo program
3
 * \author Copyright (C) 2011  Julien Le Sech - www.idreammicro.com
4
 * \version 1.0
5
 * \date 20110801
6
 *
7
 * This file is part of the MAX7219 library for Arduino.
8
 *
9
 * This library is free software: you can redistribute it and/or modify it under
10
 * the terms of the GNU Lesser General Public License as published by the Free
11
 * Software Foundation, either version 3 of the License, or (at your option) any
12
 * later version.
13
 *
14
 * This library is distributed in the hope that it will be useful, but WITHOUT
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public License
20
 * along with this program. If not, see http://www.gnu.org/licenses/
21
 ******************************************************************************/
22
 
23
/**************************************************************************//**
24
 * \file MAX7219.pde
25
 ******************************************************************************/
26
 
27
/******************************************************************************
28
 * Header file inclusions.
29
 ******************************************************************************/
30
 
31
#include <WProgram.h>
32
 
33
#include <SPI.h>
34
 
35
#include <MAX7219.h>
36
 
37
/******************************************************************************
38
 * Private variable declaration.
39
 ******************************************************************************/
40
 
41
static MAX7219 max7219(10);
42
 
43
/******************************************************************************
44
 * Public function definitions.
45
 ******************************************************************************/
46
 
47
/**************************************************************************//**
48
 * \fn void setup()
49
 ******************************************************************************/
50
void setup()
51
{
52
    // Initiliaze MAX7219.
53
    max7219.initialize();
54
    // Set scan limit.
55
    max7219.setScanLimit(MAX7219::ScanLimit_Digit0To7);
56
     // Set decode mode.
57
    max7219.setDecodeMode(MAX7219::DecodeMode_AllDigits);
58
    // Set intensity.
59
    max7219.setIntensity(MAX7219::Intensity_Level15);
60
    // Set shutdown mode.
61
    max7219.setShutdownMode(MAX7219::ShutdownMode_NormalOperation);
62
}
63
 
64
/**************************************************************************//**
65
 * \fn void loop()
66
 ******************************************************************************/
67
void loop()
68
{
69
    // To write digit values, a loop may be more elegant but a bit more
70
    // complicated for this example.
71
 
72
    // Write digit 0 value.
73
    max7219.writeDigit(MAX7219::Digit_0, MAX7219::Character_Zero);
74
    // Write digit 1 value.
75
    max7219.writeDigit(MAX7219::Digit_1, MAX7219::Character_One);
76
    // Write digit 2 value.
77
    max7219.writeDigit(MAX7219::Digit_2, MAX7219::Character_Two);
78
    // Write digit 3 value.
79
    max7219.writeDigit(MAX7219::Digit_3, MAX7219::Character_Three);
80
    // Write digit 4 value.
81
    max7219.writeDigit(MAX7219::Digit_4, MAX7219::Character_Four);
82
    // Write digit 5 value.
83
    max7219.writeDigit(MAX7219::Digit_5, MAX7219::Character_Five);
84
    // Write digit 6 value.
85
    max7219.writeDigit(MAX7219::Digit_6, MAX7219::Character_Six);
86
    // Write digit 7 value.
87
    max7219.writeDigit(MAX7219::Digit_7, MAX7219::Character_Seven);
88
 
89
    // Wait a little before next loop.
90
    delay(1000);
91
}