Multi-function shield

multi-function-shield

Bien veiller à l’isolation (en ajoutant si nécessaire un ruban isolant) entre les contacts de l’afficheur et la prise USB de l’Arduino.

A tester : http://www.cohesivecomputing.co.uk/hackatronics/arduino-multi-function-shield/ avec les librairies TimerOne et Multi avec les exemples

http://www.cohesivecomputing.co.uk/hackatronics/arduino-multi-function-shield/part-1/

http://www.cohesivecomputing.co.uk/hackatronics/arduino-multi-function-shield/part-2/

http://www.cohesivecomputing.co.uk/hackatronics/arduino-multi-function-shield/part-3/

Utilisation de la librairie pour lire la température sur une sonde Dallas:

Branchements :

Sketch :

 #include <TimerOne.h>  
 #include <Wire.h>  
 #include <MultiFuncShield.h>  
 #include <OneWire.h> //Librairie du bus OneWire   
 #include <DallasTemperature.h> //Librairie du capteur   
 OneWire oneWire(A4); //Bus One Wire sur la pin 2 de l'arduino  
 DallasTemperature sensors(&oneWire); //Utilistion du bus Onewire pour les capteurs  
 DeviceAddress sensorDeviceAddress; //Vérifie la compatibilité des capteurs avec la librairie  
 float nOld ;  
 void setup() {  
  Timer1.initialize();  
  MFS.initialize(&Timer1);  // initialize multifunction shield library  
  MFS.write(0);  
  sensors.begin(); //Activation des capteurs  
  sensors.getAddress(sensorDeviceAddress, 0); //Demande l'adresse du capteur à l'index 0 du bus  
  sensors.setResolution(sensorDeviceAddress, 12); //Résolutions possibles: 9,10,11,12  
 }  
 void loop() {  
  sensors.requestTemperatures(); //Demande la température aux capteurs  
  float nNew = sensors.getTempCByIndex(0);  
  if (nNew != nOld)  
  { nOld = nNew;  
   MFS.write(nNew);  
  }  
  delay(2);  
 }  

http://arduinolearning.com/code/multi-function-shield-examples.php

https://www.mpja.com/download/hackatronics-arduino-multi-function-shield.pdf

Unit PIN #
4 red LEDs 10, 11, 12, 13
3 buttons + reset button A1, A2, A3
Potentiometer (10 kOhm) A0
4-digit 7-sement LED tube driven by 74HC595 Latch 4, Clock 7, Data 8
Buzzer (loud speaker/beeper) 3 (digital On/Off)
Socket for infrared receiver (remote control) 2
Socket for temperature sensor LM35 or DS18B20 A4
Header for APC220 shield GND, +5v, 0, 1 (rx/tx)
Connecteur (pwm) 5, 6, 9, A5

et  4 pins GND et 4 pins +5V

 

Utilisation d’un capteur LM35

ds1820ds1820-2

 /*  
  * Temperature Sensor Displayed on 4 Digit 7 segment common anode  
  * Created by Rui Santos, http://randomnerdtutorials.com  
 */  
 const int digitPins[4] = {  
  4,5,6,7};         //4 common anode pins of the display  
 const int clockPin = 7;  //74HC595 Pin 7 
 const int latchPin = 4;  //74HC595 Pin 4  
 const int dataPin = 8;   //74HC595 Pin 8  
 const int tempPin = A4;   //temperature sensor pin  
 const byte digit[10] =   //seven segment digits in bits  
 {  
  B00111111, //0  
  B00000110, //1  
  B01011011, //2  
  B01001111, //3  
  B01100110, //4  
  B01101101, //5  
  B01111101, //6  
  B00000111, //7  
  B01111111, //8  
  B01101111 //9  
 };  
 int digitBuffer[4] = {  
  0};  
 int digitScan = 0, flag=0, soft_scaler = 0;  
 ;  
 float tempK, tempC, tempF, temp;  
 void setup(){          
  for(int i=0;i<4;i++)  
  {  
   pinMode(digitPins[i],OUTPUT);  
  }  
  pinMode(tempPin, INPUT);  
  pinMode(latchPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);  
  pinMode(dataPin, OUTPUT);   
  pinMode(tempPin, INPUT);  
 }  
 //writes the temperature on display  
 void updateDisp(){  
  for(byte j=0; j<4; j++)       digitalWrite(digitPins[j], LOW);     digitalWrite(latchPin, LOW);      shiftOut(dataPin, clockPin, MSBFIRST, B11111111);     digitalWrite(latchPin, HIGH);     delayMicroseconds(100);     digitalWrite(digitPins[digitScan], HIGH);      digitalWrite(latchPin, LOW);      if(digitScan==2)      shiftOut(dataPin, clockPin, MSBFIRST, ~(digit[digitBuffer[digitScan]] | B10000000)); //print the decimal point on the 3rd digit     else      shiftOut(dataPin, clockPin, MSBFIRST, ~digit[digitBuffer[digitScan]]);     digitalWrite(latchPin, HIGH);     digitScan++;     if(digitScan>3) digitScan=0;   
 }  
 void loop(){   
  tempK = (((analogRead(tempPin)/ 1023.0) * 5.0) * 100.0);   
  //Converts Kelvin to Celsius minus 2.5 degrees error  
  tempC = tempK - 273.0;    
  tempF = ((tempK - 2.5) * 9 / 5) - 459.67;  
  //Celsius temperature display  
  tempC = int(tempC*100);  
  digitBuffer[3] = int(tempC)/1000;  
  digitBuffer[2] = (int(tempC)%1000)/100;  
  digitBuffer[1] = (int(tempC)%100)/10;  
  digitBuffer[0] = (int(tempC)%100)%10;  
  updateDisp();  
  delay(2);  
  /*  
  //Fahrenheit temperature display  
  tempF = int(tempF*100);  
  digitBuffer[3] = int(tempF)/1000;  
  digitBuffer[2] = (int(tempF)%1000)/100;  
  digitBuffer[1] = (int(tempF)%100)/10;  
  digitBuffer[0] = (int(tempF)%100)%10;  
  updateDisp();  
  delay(2);  
  */  
 }  

Références :

http://makbit.com/web/firmware/multi-function-shield-for-arduino/

http://arduinolearning.com/code/multi-function-shield-examples.php

http://randomnerdtutorials.com/arduino-temperature-displayed-on-4-digit-7-segment/

Publicités
Articles récents
Commentaires récents
fatima dans Bienvenue !
AdminDroid dans Bienvenue !
fatima dans Bienvenue !
Archives
Catégories
%d blogueurs aiment cette page :