Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
System.Hardware.Arduino.SamplePrograms.SevenSegment
Description
Control a single seven-segment display, echoing user's key presses on it verbatim. We use a shift-register to reduce the number of pins we need on the Arduino to control the display.
Synopsis
- sr :: SR_74HC595
- sevenSegment :: IO ()
Documentation
sr :: SR_74HC595 Source #
Connections for the Texas Instruments 74HC595 shift-register. Datasheet: http://www.ti.com/lit/ds/symlink/sn74hc595.pdf.
In our circuit, we merely use pins 8 thru 12 on the Arduino to control the serial
, enable
, rClock
, sClock
, and nClear
lines, respectively. Since we do not need to read the output of the shift-register, we leave the mbBits
field unconnected.
sevenSegment :: IO () Source #
Seven-segment display demo. For each key-press, we display an equivalent pattern on the connected 7-segment-display. Note that most characters are not-mappable, so we use approximations if available. We use a shift-register to reduce the pin requirements on the Arduino, setting the bits serially.
Parts:
- The seven-segment digit we use is a common-cathode single-digit display, such as TDSG5150 (http://www.vishay.com/docs/83126/83126.pdf), or Microvity's IS121, but almost any such digit would do. Just pay attention to the line-connections, and do not forget the limiting resistors: 220 ohm's should do nicely.
- The shift-register is Texas-Instruments 74HC595: http://www.ti.com/lit/ds/symlink/sn74hc595.pdf.
Make sure to connect the register output lines to the seven-segment displays with the corresponding
letters. That is, shift-registers
Q_A
(Chip-pin 15) should connect to segmentA
;Q_B
(Chip-pin 1) to segmentB
, and so on. We do not use the shift-registerQ_H'
(Chip-pin 9) in this design.