Rev 4 | 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 | /**************************************************************************//** |
||
4 | jlesech | 24 | * \file MAX7219.ino |
2 | jlesech | 25 | ******************************************************************************/ |
26 | |||
27 | /****************************************************************************** |
||
28 | * Header file inclusions. |
||
29 | ******************************************************************************/ |
||
30 | |||
31 | #include <SPI.h> |
||
32 | |||
33 | #include <MAX7219.h> |
||
34 | |||
35 | /****************************************************************************** |
||
36 | * Private variable declaration. |
||
37 | ******************************************************************************/ |
||
38 | |||
39 | static MAX7219 max7219(10); |
||
40 | |||
41 | /****************************************************************************** |
||
42 | * Public function definitions. |
||
43 | ******************************************************************************/ |
||
44 | |||
45 | /**************************************************************************//** |
||
46 | * \fn void setup() |
||
47 | ******************************************************************************/ |
||
48 | void setup() |
||
49 | { |
||
50 | // Initiliaze MAX7219. |
||
51 | max7219.initialize(); |
||
52 | // Set scan limit. |
||
53 | max7219.setScanLimit(MAX7219::ScanLimit_Digit0To7); |
||
54 | // Set decode mode. |
||
55 | max7219.setDecodeMode(MAX7219::DecodeMode_AllDigits); |
||
56 | // Set intensity. |
||
57 | max7219.setIntensity(MAX7219::Intensity_Level15); |
||
58 | // Set shutdown mode. |
||
59 | max7219.setShutdownMode(MAX7219::ShutdownMode_NormalOperation); |
||
60 | } |
||
61 | |||
62 | /**************************************************************************//** |
||
63 | * \fn void loop() |
||
64 | ******************************************************************************/ |
||
65 | void loop() |
||
66 | { |
||
67 | // To write digit values, a loop may be more elegant but a bit more |
||
68 | // complicated for this example. |
||
69 | |||
70 | // Write digit 0 value. |
||
71 | max7219.writeDigit(MAX7219::Digit_0, MAX7219::Character_Zero); |
||
72 | // Write digit 1 value. |
||
73 | max7219.writeDigit(MAX7219::Digit_1, MAX7219::Character_One); |
||
74 | // Write digit 2 value. |
||
75 | max7219.writeDigit(MAX7219::Digit_2, MAX7219::Character_Two); |
||
76 | // Write digit 3 value. |
||
77 | max7219.writeDigit(MAX7219::Digit_3, MAX7219::Character_Three); |
||
78 | // Write digit 4 value. |
||
79 | max7219.writeDigit(MAX7219::Digit_4, MAX7219::Character_Four); |
||
80 | // Write digit 5 value. |
||
81 | max7219.writeDigit(MAX7219::Digit_5, MAX7219::Character_Five); |
||
82 | // Write digit 6 value. |
||
83 | max7219.writeDigit(MAX7219::Digit_6, MAX7219::Character_Six); |
||
84 | // Write digit 7 value. |
||
85 | max7219.writeDigit(MAX7219::Digit_7, MAX7219::Character_Seven); |
||
86 | |||
87 | // Wait a little before next loop. |
||
88 | delay(1000); |
||
89 | } |