Rob's web

Multi function shield

mfs

Warning

Alvorens de mfs op de uno te plaatsen eerst de pinnen van het display zo kort mogelijk afknippen en isolatie over de usb connector plakken i.v.m. mogelijke kortsluiting.

Kenmerken

Led display

LED display
Schema display module.

Aansturing
PinFunctionDiscription 
4LCHCLKLatch clockactive low
7SFTCLKShift clockactive low
8SDISerial data in 

Display aansturing

De aansturing is gemultiplexed.

Aanstuurcodes digits
 abcdefghHEXindex
-000000000x000
1100000000x801
2010000000x402
3001000000x203
4000100000x104
Aanstuurcodes segmenten
 Zonder dpMet dp
abcdefgdpHEXindexHEXindex
0000000110x0300x0216
1100111110x9F10x9E17
2001001010x2520x2418
3000011010x0D30x0C19
4100110010x9940x9820
5010010010x4950x4821
6010000010x4160x4022
7000111110x1F70x1E23
8000000010x0180x0024
9000010010x0990x0825
A000100010x11100x1026
B110000010xC1110xC027
C011000110x63120x6228
D100001010x85130x8429
E011000010x61140x6030
F011100010x71150x7031
 111111110xFF320xFE33
Segmenten 
dp111111100xFF33
sa011111110x7F34
sb101111110xBF35
sc110111110xDF36
sd111011110xEF37
se111101110xF738
sf111110110xFB39
sg111111010xFD40

Code

De numMap[] is voor hexadecimaal (0-F) gebruik. Voor gebruik van de decimale punt de tabel uitbreiden in de volgorde van de indexnummers.

const byte numMap[] = {0x03, 0x9F, 0x25, 0x0D, 0x99, 0x49, 0x41, 0x1F, 0x01, 0x09, 0x11, 0xC1, 0x63, 0x85, 0x61, 0x71, 0xFF};
const byte digitMap[] = {0x00, 0x80, 0x40, 0x20, 0x10};

Voor ieder digit run de onderstaande code. Value is de index zoals vermeld in de codetabel.

void dispNum(int digitNum, int Value) {
  digitalWrite(D_LATCH, LOW);
  shiftOut(D_DATA, D_CLK, LSBFIRST, numMap[Value]);
  shiftOut(D_DATA, D_CLK, LSBFIRST, digitMap[digitNum]);
  digitalWrite(D_LATCH, HIGH);
}

Na het aansturen van de vier digits de code met dispNum(0, 32) draaien om te zorgen dat het laatste display niet helderder brand dan de eerste drie.

SMD leds

LED gaat branden als de poort laag wordt.

Leds

Trimpotentiometer

De loper van de potmeter geeft een spanning tussen 0 en 5 V aan A0.

Potmeter

Drukknoppen

De drukknopen S1, S2, S3 zetten 0 V op resp. A1, A2 of A3. In rust is dit 5 V.

Drukknoppen

Piëzo zoemer

De zoemer gaat aan als 3 laag wordt.

zoemer

IR ontvangerinterface U4

IR ontvangerchip

DS18B20 en LM35 interface U5

temp interface

ds18b20lm35

Sensor en actuator interface

Voor sensor en actuator gebruik zijn de poorten 5, 6, 9 en A5 beschikbaar. De sensoren en actuators worden vanaf hier gevoed met 5 V.

Sensor interface

Seriële interface

apc220

Programming

Let's define the board to make it easier to program

One of the convenient features of programming in Arduino is that you can define names to represent the Arduino pins. As you program, it is easy to remember that BUZZER is the pin that the buzzer is connected to. We will use a name for each of the features so we can make our code easier to read and write. Here is how we do that:

#define LED_1 13 // LED pins
#define LED_2 12
#define LED_3 11
#define LED_4 10
#define BUZZER 3 // The buzzer
#define IR 2
#define POTMETER A0 // The analog input for the potentiometer
#define BUTTON_1 A1 // The input pushbuttons
#define BUTTON_2 A2
#define BUTTON_3 A3
#define TEMP A4
#define DISP_LATCH 4 // The 3 pins that control the display
#define DISP_CLK 7
#define DISP_DATA 8

If you insert these #define statements in the beginning of your Arduino code, you will now be able to refer to the features by their name instead of their pin number.

Setup

The next thing you usually want to do is set up the pinMode for each of these features. If you are a veteran Arduino programmer, you will have noticed that most libraries will do this for pins the library is going to use. However, it is good practice to ensure the pins are setup to your liking. In your setup() procedure you would want the following pinMode() commands:

First, set the LED pins as outputs:

pinMode(LED_1, OUTPUT);
pinMode(LED_2, OUTPUT);
pinMode(LED_3, OUTPUT);
pinMode(LED_4, OUTPUT);

Write this pins high so they will turn off the LEDs:

digitalWrite(LED_1, HIGH);
digitalWrite(LED_2, HIGH);
digitalWrite(LED_3, HIGH);
digitalWrite(LED_4, HIGH);

Next, set the pushbuttons as inputs (there are pullup resistors on the board so there is no need for the internal pullups).

pinMode(BUTTON_1, INPUT);
pinMode(BUTTON_2, INPUT);
pinMode(BUTTON_3, INPUT);

Set the buzzer as an output:

pinMode(BUZZER, OUTPUT);

And turn it off:

digitalWrite(BUZZER, HIGH);

Set the IR poort.

pinMode(IR, INPUT);

Finally, define the display pins as outputs:

pinMode(DISP_LATCH, OUTPUT);
pinMode(DISP_CLK, OUTPUT);
pinMode(DISP_DATA, OUTPUT);

That finishes our setup for using the board. You can find the full setup code in this sketch. Put your code in the loop.

The library for this shield only works with the UNO and not with others.

Docs

Projecten met de MFS

Overige multi function shields

DHT11 - LM35 multi function shield

DHT11 LM35 mfs