You are on page 1of 5
snazote ‘mull function shield examples « Infra-red control and RGB led example Random flashing multi function shield examples This shield got my attention as it looked like a nice beginners learning type shield with which you could get up and running with an Arduino Here is a picture of the board, a few code examples are available later on in the article. ee Te e0ees aad Soa eo Soap a) Ey ea ereemercry ‘multi function shield Features 4 digit 7-segment LED display module driven by two serial 741C595's 4LED's 10K potentiometer 3x push buttons. Piezo buzzer 1DS18B20 temperature sensor interface (not included) Infrared receiver interface Serial interface header for connection to serial modules Code Examples Blinking LED 1| int led = 13; 2 3| void setup() al ¢ 5 | // initialize the digital pin as an output. ntplfardunoleaming.com/eodeimuli-unction-shield-examples.php MAX7219 example » 18 snazote ‘mult funtion shield examples pinMode(1ed, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay (1008) ; digitalwrite(led, Low); delay( 1000) ; d All LEDS blinking int ledi int led2 int led3 = 113 int ledd = 10; void setup() // initialize the digital pin as an output. PinMode(ledi, OUTPUT); pinMode(1ed2, OUTPUT); pinMode(1ed3, OUTPUT); pinMode(led@, OUTPUT) ; } void loop() digitalwrite(led1, HIGH); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalurite(led4, HIGH); delay (1000) ; digitalWrite(led1, Low); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalurite(led4, LOW); delay(1000) ; } ‘Switches example const byte LED[] = (13,12,11,16); define BUTTON AL fidefine BUTTON2 A2 void setup() // initialize the digital pin as an output. 7* Set each pin to outputs */ Pintiode(LED[@], OUTPUT); pintode(LED[3], OUTPUT); pintode(LED[2], OUTPUT); pinMode(LeD[3]; OUTPUT); } void Lo0p() if(IdigitalRead(BUTTON1) ) { digitalwrite(Leofe], HIGH); digitalWrite(LeD[1], HIGH); digitalWrite(LeD[2], HIGH); digitalWrite(LeD[3], HIGH); > if (IdigitalRead(BUTTON2) ) { digitalWrite(Lep[a], Low); hitplarduinolearning.concodeimultfunction-shielé- examples, php 2s snazote ‘mult funtion shield examples 29 | digitalwrite(Leo[1), Low); 30| digitalWrite(LeD[2], LOW); 31 | digitalWrite(LeD[3], LOW); 32| } 33| } Potentiometer 1 1] tdefine Pott @ 2 3| void setup() ait S| Serial. begin(96e@) ; 6) } 7 8 | /* Main Program */ 9| void 1o0p() ro} ¢ a 12 | Serial.print(“Potentioneter readin 13 | Serial println(analogkead(Pot1)); 14] 7/* wait 0.5 seconds before reading again */ 15 | delay(5e0); as! } Pot and led 1| const byte LeD[] = (13,12,21,1@}5 2| define Pott @ 3 4| void setup() 5 6 | Serial.begin(9608); 7| // initialize the digital pin as an output. 8| /* Set each pin to outputs */ 9 | pinMode(Lep[e], OUTPUT); 10 | pinMode(LeD[a]; OUTPUT); 11 | pinMode(Leo[2]; OUTPUT); 12 | pinMode(LeD[3], OUTPUT); |} a 15 | /* Main Progeam */ 16 | void loop) wv} ¢ 18 | int potvalue; 19 | //Serial.print(“Potentioneter reading: “); 20 | PotValue = analogread(Pot1); 21) /* Wait @.5 seconds before reading again */ 22 | if(PotValue < 400) 23) { 24 | digitalurite(Leo[a], Low); 25 | digitalwrite(Leo[1], Low); 26 | digitalWrite(Led[2], LOW); 27 | digitalWrite(LeED[3], LOW); 28 | Serial.print(“Potentioneter: “); 29 | Serial println(PotValue) ; 30) } 31| else 32} ¢ 33| digitalwrite(.eo[o], HIGH); 34 | digitalWrite(Leo[1]; HIGH); 35 | digitalWrite(LeD[2], HIGH); 36 | digitalWrite(LED[3], HIGH); 37 | Serial.print(“Potentioneter: “); 38 | Serial println(PotValue) ; 39| } 40 | delay(5ee) ; al} hitplarduinolearning.concodeimultfunction-shielé- examples, php 35 snazote ‘mult funtion shield examples ‘segment display /* Define shift register pins used for seven segnent display */ define LATCH_DIO 4 define CLK_DIO 7 fidefine DATA_DIO & 7* Segment byte maps for numbers @ to 9 */ const byte SEGMENT MAP[] = {@xC@,@xF9,@xA4, 0x80, 0x99, 0x92, 0x82, 0XxF8, 0X80, 0X90}; /* Byte maps to select digit 1 to 4 */ const byte SEGMENT_SELECT[] = {OxF1,0xF2, 0xF4, OxF8); void setup () 7* Set DIO pins to outputs */ pinMode(LATCH_DIO, OUTPUT) ; pinMode(CLK_DT0, OUTPUT) ; pinMode(DATA_DTO, OUTPUT) ; } 7* Main program */ void loop() t /* Update the display with the current counter value */ WriteNunberToSegment(® , 2); WriteNunberToSegment(1 ; 1) WriteNumberToSegment(2 , 2); WriteNumberToSegment(3 , 3); } /* write a decimal number between @ and 9 to one of the 4 digits of the display */ void WiniteNumberToSegment(byte Segment, byte Value) { digitalwrite(LATCH_D10, LOW); ShiftOut(DATA_DIO, CLK DIO, MSBFIRST, SEGMENT MAP[Value]); shiftOut(DATADIO, CLK DIO, MSBFIRST, SEGMENT_SELECT [Segment] ); digitalWrite(LATCh_010,HIGH); ) Read pot and display value on display /* Define shift register pins used for seven segnent display */ fideFine LATCH_D10 4 fidefine CLK_pT0 7 define DATA_DIO 8 define Potl @ /* Segment byte maps for nurbers @ to 9 */ Const byte SEGMENT MAP[] = {@xC0, OxF9, 0xA4, 0x80, 0x99, 0x92, @x82, OxF8, OXB2,0x90); /* Byte maps to select digit 1 to 4 */ const byte SEGMENT SELECT[] = {@xF1,0xF2,@xF4, @xF8)5 void setup () Serial .begin(9600); 7* Set DIO pins to outputs */ pinMode(LATCH_DIO, OUTPUT) ; pinMode(CLK_DI0, OUTPUT) ; pinMode(DATA_DTO, OUTPUT) ; , 7* Main program */ void 1oop() { int Potvalue; PotValue = analogRead(Pot1) Serial.print(“Potentioneter “) Serial.print1n(PotValue) ; 7* Update the display with the current counter value */ WriteNunberToSegment(@ , PotValue / 1000); WriteNumberToSegment(1 , (PotValue / 100) % 16); ntplfardunoleaming.com/eodeimuli-unction-shield-examples.php a5 snazote ‘mull function shield examples 32 | WeiteNumberToSegment(2 , (PotValue / 10) % 10); 33 | WeiteNumberToSegment(3 , PotValue % 1@); 34] } 36 | /* write a decimal number between @ and 9 to one of the 4 digits of the display */ 37 | void WriteNumberToSegment(byte Segment, byte Value) { 39 | digitalWrite(LATCH_D10, LOW); 4@ | shiftout(DATA DIO, CLK DIO, MSBFIRST, SEGMENT MAP(Value]) ; 41 | shiftout(DATA_DIO, CLK_DIO, MSBFIRST, SEGMENT_SELECT(Segment] ); 42 | digitalwrite(TATCH_D10,HIGH) ; a3| } Resources Multifunctional Expansion Board Shield Ki Share/Save BY. Related Posts: 1, H€-SR04 Ultrasonic Sensor example 2. Basic voltmeter 3, Infrared receiver example 4, Arduino and Tm1638 button example Comments are closed. hitplarduinolearning.concodeimultfunction-shielé- examples, php 55

You might also like