SlideShare a Scribd company logo
Arduino Final Project

By: Mhmoud Salama.
    Hussam Hamdy.
Main Project
• To make a temperature sensor that outputs the reading
  as a scrolling message on a LED matrix.
• We used a LED matrix which is a common anode 8x8
  display.
• Wired on breadboards.
Main Concept
• Use of two shift registers (2x 74HC595) to pass the
  encoded-charachter data serially from the arduino as a
  parallel output to the rows and Columns of an 8x8 LED
  matrix.

• The arduino handles the scrolling of the message and the
  periodic time-multiplexing of rows and columns (refresh
  rate = 100Hz), using a periodic interrupt, to which the
  function “screenUpdate” is attached.

• So , we calibrated the sensor using a potentiometer
  through the serial monitor window.
• then the complete circuit is connected.
Wiring Diagram
74HC595-Shift Registers




-- An 8-bit shift register with
Serial to parallel capability.
-- We use two of them, Each
one controlling eight
rows/columns.
LM335-Temperature Sensor
• Calibration:

 -- We connect the calibration circuit , and
 connected it’s output as an analogue input to
 the arduino.

 -- With a potentiometer, and a small code...
 we used the serial monitor of arduino to
  fine-tune the sensor to give an acceptable
 reading (28 C for average room temperature).
CODE
•   #include <TimerOne.h>
•   #include <charEncodings.h>           // Each charachter and it’s (8x8 LED matrix)-mapped code.

•   // BASIC PIN CONFIGURATION
•   // AND DECLARATIONS

•   //Pin connected to Pin 12 of 74HC595 (Latch)
•   int latchPin = 8;
•   //Pin connected to Pin 11 of 74HC595 (Clock)
•   int clockPin = 12;
•   //Pin connected to Pin 14 of 74HC595 (Data)
•   int dataPin = 11;

•   // pin for the potentiometer to control the scrolling speed
•   int potPin = 5;

•   // pin for reading the temperature
•   int tempPin = 4;

•   // this is the gobal array that represents what the matrix
•   // is currently displaying
•   uint8_t led[8];
CODE
• void setup()
• {
    //set pins to output
•     pinMode(latchPin, OUTPUT);
•     pinMode(clockPin, OUTPUT);
•     pinMode(dataPin, OUTPUT);
•     pinMode(potPin, INPUT);
•     pinMode(tempPin, INPUT);
•     analogReference(INTERNAL);

•     // attach the screenUpdate function to the interrupt timer
•   // Period=10,000micro-second /refresh rate =100Hz
•   Timer1.initialize(10000);
•   Timer1.attachInterrupt(screenUpdate);
•   }
CODE
• //Continuous LOOP
• void loop()
• {
• long counter1 = 0;
• long counter2 = 0;
• char reading[10];
• char buffer[18];

•     if (counter1++ >=100000) {
•       counter2++;
•     }
•     if (counter2 >= 10000) {
•       counter1 = 0;
•       counter2 = 0;
•     }

    getTemp(reading);
    displayScrolledText(reading);
}
The (displayScrolledText ) Function

•   void displayScrolledText(char* textToDisplay)
•   {

•    int textLen = strlen(textToDisplay);
•    char charLeft, charRight;

•    // scan through entire string one column at a time and call
•    // function to display 8 columns to the right
•    for (int col = 1; col <= textLen*8; col++)
•   {
•
•       // if (col-1) is exact multiple of 8 then only one character
•       // involved, so just display that one

•       if ((col-1) % 8 == 0 )
•   {
•           char charToDisplay = textToDisplay[(col-1)/8];
•
•   for (int j=0; j<8; j++)
•      {
•        led[j] = charBitmaps[charToDisplay][j];
•      }

•       }

•           else
•       {
•           int charLeftIndex = (col-1)/8;
•           int charRightIndex = (col-1)/8+1;

•           charLeft = textToDisplay[charLeftIndex];
• // check we are not off the end of the string
•     if (charRightIndex <= textLen)
•     {
•       charRight = textToDisplay[charRightIndex];
•     }
•     else
•     {
•       charRight = ' ';
•     }
•     setMatrixFromPosition(charLeft, charRight, (col-1) % 8);
•   }

•       int delayTime = analogRead(potPin);

•       delay (delayTime);
•   }
•}
•   void shiftIt(byte dataOut) {
•    // Shift out 8 bits LSB first,
•    // on rising edge of clock

•    boolean pinState;

•    //clear shift register read for sending data
•    digitalWrite(dataPin, LOW);

•    // for each bit in dataOut send out a bit
•    for (int i=0; i<=7; i++) {
•     //set clockPin to LOW prior to sending bit
•     digitalWrite(clockPin, LOW);

•        // if the value of DataOut and (logical AND) a bitmask
•        // are true, set pinState to 1 (HIGH)
•        if ( dataOut & (1<<i) ) {
•          pinState = HIGH;
•        }
•        else {
•          pinState = LOW;
•        }

•        //sets dataPin to HIGH or LOW depending on pinState
•        digitalWrite(dataPin, pinState);
•        //send bit out on rising edge of clock
•        digitalWrite(clockPin, HIGH);
•        digitalWrite(dataPin, LOW);
•    }
• //stop shifting
• digitalWrite(clockPin, LOW);
• }

• boolean isKeyboardInput() {

• // returns true is there is any characters in the keyboard buffer
• return (Serial.available() > 0);
• }

• }

• // terminate the string
• readString[index] = '0';
• }
•   void setMatrixFromPosition(char charLeft, char charRight, int col) {

•       // take col left most columns from left character and bitwise OR with 8-col from
•       // the right character
•       for (int j=0; j<8; j++) {
•         led[j] = charBitmaps[charLeft][j] << col | charBitmaps[charRight][j] >> 8-col;
•       }
•   }


•   void screenUpdate() {

•       uint8_t col = B00000001;

•       for (byte k = 0; k < 8; k++) {
•        digitalWrite(latchPin, LOW); // Open up the latch ready to receive data

•        shiftIt(~led[7-k]);
•        shiftIt(col);

•        digitalWrite(latchPin, HIGH); // Close the latch, sending the registers data to the matrix
•        col = col << 1;
•       }
•       digitalWrite(latchPin, LOW);
•       shiftIt(~0 );
•       shiftIt(255);
•       digitalWrite(latchPin, HIGH);
•   }
•   void getTemp(char* reading) {

•       int span = 20;
•       int aRead = 0;
•       long temp;
•       char tmpStr[10];

•       // average out several readings
•       for (int i = 0; i < span; i++) {
•         aRead = aRead+analogRead(tempPin);
•       }

•       aRead = aRead / span;

•       temp = ((100*1.1*aRead)/1024)*10;

•       reading[0] = '0';

•       itoa(temp/10, tmpStr, 10);
•       strcat(reading,tmpStr);
•       strcat(reading, ".");
•       itoa(temp % 10, tmpStr, 10);
•       strcat(reading, tmpStr);
•       strcat(reading, "C");

•   }

More Related Content

PPTX
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
PDF
Registers and counters
DOCX
32 bit ALU Chip Design using IBM 130nm process technology
PDF
Central processing unit
PPTX
PPTX
PPTX
PPTX
Relay and AVR Atmel Atmega 16
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Registers and counters
32 bit ALU Chip Design using IBM 130nm process technology
Central processing unit
Relay and AVR Atmel Atmega 16

What's hot (20)

PPTX
Input Output programming in AVR microcontroller
PPTX
Unix signals
PDF
Experiment write-vhdl-code-for-realize-all-logic-gates
PDF
The IoT Academy IoT Training Arduino Part 3 programming
DOCX
Alu description[1]
PPT
14827 shift registers
PDF
Arduino Workshop 2011.05.31
PPT
Digital logic design DLD Logic gates
PPTX
Registers siso, sipo
PDF
8 bit single cycle processor
ODP
FPGA Tutorial - LCD Interface
DOCX
Uart
PDF
Using Timers in PIC18F Microcontrollers
PPT
Digital logic design lecture 04
PPTX
New microsoft office power point presentation
PPTX
Logic gate
PDF
Day4 順序控制的循序邏輯實現
PDF
Shift register
PPTX
EASA Part 66 Module 5.5 : Logic Circuit
PDF
Shift registers
Input Output programming in AVR microcontroller
Unix signals
Experiment write-vhdl-code-for-realize-all-logic-gates
The IoT Academy IoT Training Arduino Part 3 programming
Alu description[1]
14827 shift registers
Arduino Workshop 2011.05.31
Digital logic design DLD Logic gates
Registers siso, sipo
8 bit single cycle processor
FPGA Tutorial - LCD Interface
Uart
Using Timers in PIC18F Microcontrollers
Digital logic design lecture 04
New microsoft office power point presentation
Logic gate
Day4 順序控制的循序邏輯實現
Shift register
EASA Part 66 Module 5.5 : Logic Circuit
Shift registers
Ad

Viewers also liked (20)

PPTX
Temperature Sensor
PPTX
CONTROL FAN AC USING TEMPERATURE SENSOR LM35 BASED ON ARDUINO UNO
DOCX
A 64-by-8 Scrolling Led Matrix Display System
PDF
5x7 matrix led display
PPTX
Automatic DC Fan using LM35 (english version)
DOC
Moving message display
PPTX
Arduino Workshop
PDF
Catalogo unitronics 2012_intrave
PPTX
8x8 dot matrix(project)
PPTX
Introduction to Arduino
PPTX
Temperature Controller with Atmega16
PDF
Automatic room temperature controlled fan using arduino uno microcontroller
PPTX
Home automation
PDF
PDF
Control Fan AC With LM-35 Sensor Based Arduino
PPTX
HEALTH MONITORING SYSTEM using mbed NXP LPC11U24
PDF
PPTX
131080111003 mci
PDF
PPTX
Digital Notice Board
Temperature Sensor
CONTROL FAN AC USING TEMPERATURE SENSOR LM35 BASED ON ARDUINO UNO
A 64-by-8 Scrolling Led Matrix Display System
5x7 matrix led display
Automatic DC Fan using LM35 (english version)
Moving message display
Arduino Workshop
Catalogo unitronics 2012_intrave
8x8 dot matrix(project)
Introduction to Arduino
Temperature Controller with Atmega16
Automatic room temperature controlled fan using arduino uno microcontroller
Home automation
Control Fan AC With LM-35 Sensor Based Arduino
HEALTH MONITORING SYSTEM using mbed NXP LPC11U24
131080111003 mci
Digital Notice Board
Ad

Similar to Temperature sensor with a led matrix display (arduino controlled) (20)

PDF
Combine the keypad and LCD codes in compliance to the following requ.pdf
PPTX
R tist
DOCX
7segment scetch
PDF
硕士答辩Keynote
PPTX
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
PDF
Arduino uno basic Experiments for beginner
PDF
Introduction to Arduino and Circuits
PPTX
Vechicle accident prevention using eye bilnk sensor ppt
PPTX
Sensors and Actuators in Arduino, Introduction
PDF
Programming arduino makeymakey
PPT
Intro2 Robotic With Pic18
PDF
Arduino: Intro and Digital I/O
PDF
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
PDF
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
PPTX
LED Cube Presentation Slides
TXT
PIC and LCD
PDF
Arduino and Robotics
DOCX
Direct analog
PPTX
Pemrograman Arduino 1
DOCX
Combine the keypad and LCD codes in compliance to the following requ.pdf
R tist
7segment scetch
硕士答辩Keynote
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino uno basic Experiments for beginner
Introduction to Arduino and Circuits
Vechicle accident prevention using eye bilnk sensor ppt
Sensors and Actuators in Arduino, Introduction
Programming arduino makeymakey
Intro2 Robotic With Pic18
Arduino: Intro and Digital I/O
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
LED Cube Presentation Slides
PIC and LCD
Arduino and Robotics
Direct analog
Pemrograman Arduino 1

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Spectroscopy.pptx food analysis technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
Spectral efficient network and resource selection model in 5G networks
Chapter 3 Spatial Domain Image Processing.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Programs and apps: productivity, graphics, security and other tools
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
The AUB Centre for AI in Media Proposal.docx

Temperature sensor with a led matrix display (arduino controlled)

  • 1. Arduino Final Project By: Mhmoud Salama. Hussam Hamdy.
  • 2. Main Project • To make a temperature sensor that outputs the reading as a scrolling message on a LED matrix. • We used a LED matrix which is a common anode 8x8 display. • Wired on breadboards.
  • 3. Main Concept • Use of two shift registers (2x 74HC595) to pass the encoded-charachter data serially from the arduino as a parallel output to the rows and Columns of an 8x8 LED matrix. • The arduino handles the scrolling of the message and the periodic time-multiplexing of rows and columns (refresh rate = 100Hz), using a periodic interrupt, to which the function “screenUpdate” is attached. • So , we calibrated the sensor using a potentiometer through the serial monitor window. • then the complete circuit is connected.
  • 5. 74HC595-Shift Registers -- An 8-bit shift register with Serial to parallel capability. -- We use two of them, Each one controlling eight rows/columns.
  • 6. LM335-Temperature Sensor • Calibration: -- We connect the calibration circuit , and connected it’s output as an analogue input to the arduino. -- With a potentiometer, and a small code... we used the serial monitor of arduino to fine-tune the sensor to give an acceptable reading (28 C for average room temperature).
  • 7. CODE • #include <TimerOne.h> • #include <charEncodings.h> // Each charachter and it’s (8x8 LED matrix)-mapped code. • // BASIC PIN CONFIGURATION • // AND DECLARATIONS • //Pin connected to Pin 12 of 74HC595 (Latch) • int latchPin = 8; • //Pin connected to Pin 11 of 74HC595 (Clock) • int clockPin = 12; • //Pin connected to Pin 14 of 74HC595 (Data) • int dataPin = 11; • // pin for the potentiometer to control the scrolling speed • int potPin = 5; • // pin for reading the temperature • int tempPin = 4; • // this is the gobal array that represents what the matrix • // is currently displaying • uint8_t led[8];
  • 8. CODE • void setup() • { //set pins to output • pinMode(latchPin, OUTPUT); • pinMode(clockPin, OUTPUT); • pinMode(dataPin, OUTPUT); • pinMode(potPin, INPUT); • pinMode(tempPin, INPUT); • analogReference(INTERNAL); • // attach the screenUpdate function to the interrupt timer • // Period=10,000micro-second /refresh rate =100Hz • Timer1.initialize(10000); • Timer1.attachInterrupt(screenUpdate); • }
  • 9. CODE • //Continuous LOOP • void loop() • { • long counter1 = 0; • long counter2 = 0; • char reading[10]; • char buffer[18]; • if (counter1++ >=100000) { • counter2++; • } • if (counter2 >= 10000) { • counter1 = 0; • counter2 = 0; • } getTemp(reading); displayScrolledText(reading); }
  • 10. The (displayScrolledText ) Function • void displayScrolledText(char* textToDisplay) • { • int textLen = strlen(textToDisplay); • char charLeft, charRight; • // scan through entire string one column at a time and call • // function to display 8 columns to the right • for (int col = 1; col <= textLen*8; col++) • { • • // if (col-1) is exact multiple of 8 then only one character • // involved, so just display that one • if ((col-1) % 8 == 0 ) • { • char charToDisplay = textToDisplay[(col-1)/8]; • • for (int j=0; j<8; j++) • { • led[j] = charBitmaps[charToDisplay][j]; • } • } • else • { • int charLeftIndex = (col-1)/8; • int charRightIndex = (col-1)/8+1; • charLeft = textToDisplay[charLeftIndex];
  • 11. • // check we are not off the end of the string • if (charRightIndex <= textLen) • { • charRight = textToDisplay[charRightIndex]; • } • else • { • charRight = ' '; • } • setMatrixFromPosition(charLeft, charRight, (col-1) % 8); • } • int delayTime = analogRead(potPin); • delay (delayTime); • } •}
  • 12. void shiftIt(byte dataOut) { • // Shift out 8 bits LSB first, • // on rising edge of clock • boolean pinState; • //clear shift register read for sending data • digitalWrite(dataPin, LOW); • // for each bit in dataOut send out a bit • for (int i=0; i<=7; i++) { • //set clockPin to LOW prior to sending bit • digitalWrite(clockPin, LOW); • // if the value of DataOut and (logical AND) a bitmask • // are true, set pinState to 1 (HIGH) • if ( dataOut & (1<<i) ) { • pinState = HIGH; • } • else { • pinState = LOW; • } • //sets dataPin to HIGH or LOW depending on pinState • digitalWrite(dataPin, pinState); • //send bit out on rising edge of clock • digitalWrite(clockPin, HIGH); • digitalWrite(dataPin, LOW); • }
  • 13. • //stop shifting • digitalWrite(clockPin, LOW); • } • boolean isKeyboardInput() { • // returns true is there is any characters in the keyboard buffer • return (Serial.available() > 0); • } • } • // terminate the string • readString[index] = '0'; • }
  • 14. void setMatrixFromPosition(char charLeft, char charRight, int col) { • // take col left most columns from left character and bitwise OR with 8-col from • // the right character • for (int j=0; j<8; j++) { • led[j] = charBitmaps[charLeft][j] << col | charBitmaps[charRight][j] >> 8-col; • } • } • void screenUpdate() { • uint8_t col = B00000001; • for (byte k = 0; k < 8; k++) { • digitalWrite(latchPin, LOW); // Open up the latch ready to receive data • shiftIt(~led[7-k]); • shiftIt(col); • digitalWrite(latchPin, HIGH); // Close the latch, sending the registers data to the matrix • col = col << 1; • } • digitalWrite(latchPin, LOW); • shiftIt(~0 ); • shiftIt(255); • digitalWrite(latchPin, HIGH); • }
  • 15. void getTemp(char* reading) { • int span = 20; • int aRead = 0; • long temp; • char tmpStr[10]; • // average out several readings • for (int i = 0; i < span; i++) { • aRead = aRead+analogRead(tempPin); • } • aRead = aRead / span; • temp = ((100*1.1*aRead)/1024)*10; • reading[0] = '0'; • itoa(temp/10, tmpStr, 10); • strcat(reading,tmpStr); • strcat(reading, "."); • itoa(temp % 10, tmpStr, 10); • strcat(reading, tmpStr); • strcat(reading, "C"); • }