Topic outline

  • Topic 1

    Nokia 5111

    Graphic LCD 84x48 - Nokia 5110

    Description: The Nokia 5110 is a basic graphic LCD screen for lots of applications. It was originally intended to be used as a cell phone screen. Due to the huge number produced, they are relatively cheap, and ideal for small projects.

    It uses the PCD8544 controller, which is the same used in the Nokia 3310 LCD. The PCD8544 is a low power CMOS LCD controller/driver, designed to drive a graphic display of 48 rows and 84 columns.

    All necessary functions for the display are provided in a single chip, including on-chip generation of LCD supply and bias voltages, resulting in a minimum of external components and low power consumption. The PCD8544 interfaces to microcontrollers through a serial bus interface

    • Topic 2

      Nokia 5111 and Arduino

      Pin define:
      1. RST - Reset
      2. CE - Chip Select
      3. DC - data/instruction selection
      4. DIN - serial data line
      5. CLK - Serial Clock Line
      6. VCC - power input (3.3v or 5v)
      7. BL - backlight control
      8. GND - Ground

      Data s

      Documents:

      heet

      • Topic 3

        nnn

        • Topic 4

          Notes

          The Nokia can be controlled two ways, a cmd or sending data

          The subroutine 

          void LcdWriteCmd(byte cmd) passes in a hex value

          digitalWrite(PIN_DC, LOW); //DC pin is low for commands, high for data

          shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, cmd); thransmits serial data, with cmd having the most significant bit first 

          shiftOut()

          Description

          Shifts out a byte of data one bit at a time. Starts from either the most (i.e. the leftmost) or least (rightmost) significant bit. Each bit is written in turn to a data pin, after which a clock pin is pulsed (taken high, then low) to indicate that the bit is available.

          Note: if you're interfacing with a device that's clocked by rising edges, you'll need to make sure that the clock pin is low before the call to shiftOut(), e.g. with a call to digitalWrite(clockPin, LOW).


          #define PIN_SCE 7
          #define PIN_RESET 6
          #define PIN_DC 5
          #define PIN_SDIN 4
          #define PIN_SCLK 3
          #define PIN_SBL 2

          void LcdWriteCmd(byte cmd)
          {
          digitalWrite(PIN_DC, LOW); //DC pin is low for commands
          digitalWrite(PIN_SCE, LOW);
          shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, cmd); //transmit serial data
          digitalWrite(PIN_SCE, HIGH);
          }

          void setup()
          {
          pinMode(PIN_RESET, OUTPUT);
          pinMode(PIN_SCE, OUTPUT);
          pinMode(PIN_DC, OUTPUT);
          pinMode(PIN_SDIN, OUTPUT);
          pinMode(PIN_SCLK, OUTPUT);
          digitalWrite(PIN_RESET, LOW);
          digitalWrite(PIN_RESET, HIGH); LcdWriteCmd(0x21); // LCD extended commands
          analogWrite(PIN_SBL,255);

          LcdWriteCmd(0xB8); // set LCD Vop (contrast)
          LcdWriteCmd(0x04); // set temp coefficent
          LcdWriteCmd(0x14); // LCD bias mode 1:40
          LcdWriteCmd(0x20); // LCD basic commands
          LcdWriteCmd(0x09); // LCD all segments on
          }

          void loop()
          {
          }

          • Topic 5

            Displaying text

            • Topic 6

              Notes

              LcdWriteCmd(0x09); // LCD all segments on needs be changed to normal video. 

              Look on data sheet, normal video 

              D and E are set to 10, looking up table

              binary 1100
              dec     10
              hex     C

              therefore command is LcdWriteCmd(0x0C);

              • Topic 7

                Load graphics into Nokia 5110

                • Topic 8

                  Nokia 5110 and u8glib library

                  • Topic 9

                    Notes : u8g library

                    This library has a host of fonts and graphical screen displays useful for displaying data. Also has a large number of fonts.

                    Many supported devices
                    (SSD1325, ST7565, ST7920, UC1608, UC1610, UC1701, PCD8544, PCF8812, KS0108, LC7981, SBN1661, SSD1306, SH1106, T6963, LD7032)

                    Nokia has pcd8544

                    Strip out all else

                    13   sck      clock   3
                    11   mosi     DIN   4
                    10   cs         CE    7
                    9     a0        DC    5
                    8     reset     RST   6

                    #include "U8glib.h"

                    #define PIN_SBL   2 

                    //U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8

                    U8GLIB_PCD8544 u8g(3, 4, 7, 5, 6);  

                    === code ===

                    void draw(void) {

                      // graphic commands to redraw the complete screen should be placed here  

                      u8g.setFont(u8g_font_unifont);

                      //u8g.setFont(u8g_font_osb21);

                      u8g.drawStr( 10, 20, "Weber");

                       u8g.drawStr( 10, 40, "Science");

                       u8g.drawFrame(2,2,82,44);

                    }

                    void setup(void) {

                      // flip screen, if required

                      // u8g.setRot180();

                      

                      // set SPI backup if required

                      //u8g.setHardwareBackup(u8g_backup_avr_spi);

                      // assign default color value

                      if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {

                        u8g.setColorIndex(255);     // white

                      }

                      else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {

                        u8g.setColorIndex(3);         // max intensity

                      }

                      else if ( u8g.getMode() == U8G_MODE_BW ) {

                        u8g.setColorIndex(1);         // pixel on

                      }

                      else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {

                        u8g.setHiColorByRGB(255,255,255);

                      }

                      

                      pinMode(8, OUTPUT);

                       pinMode(2, OUTPUT);

                       digitalWrite(2,HIGH);

                    }

                    void loop(void) {

                      // picture loop

                      u8g.firstPage();  

                      do {

                        draw();

                      } while( u8g.nextPage() );

                      // rebuild the picture after some delay

                      //delay(50);

                    }

                    Download from github

                    Load library using

                    Sketch => include library => add .zip file

                    • Many supported devices (SSD1325, ST7565, ST7920, UC1608, UC1610, UC1701, PCD8544, PCF8812, KS0108, LC7981, SBN1661, SSD1306, SH1106, T6963, LD7032)
                    • Topic 10

                      dallas 18B20

                      /*
                      This is a simple sketch that read a single sensor, ds18b20

                      instructions at https://www.youtube.com/watch?v=1GD29sXLOJ0

                      */

                      #include <OneWire.h>
                      #include <DallasTemperature.h>

                      // Data wire is plugged into port 2 on the Arduino
                      #define ONE_WIRE_BUS 2

                      // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
                      OneWire oneWire(ONE_WIRE_BUS);

                      // Pass our oneWire reference to Dallas Temperature.
                      DallasTemperature sensors(&oneWire);

                      void setup(void)
                      {
                      // start serial port
                      Serial.begin(9600);
                      Serial.println("<< and so it begins >>");
                      // Start up the library
                      sensors.begin();
                      }

                      void loop(void)
                      {
                      // call sensors.requestTemperatures() to issue a global temperature
                      // request to all devices on the bus
                      Serial.print("Requesting temperatures...");
                      sensors.requestTemperatures(); // Send the command to get temperatures
                      Serial.println("DONE");
                      delay(500);
                      Serial.print("Temperature for the device 1 (index 0) is: ");
                      Serial.println(sensors.getTempCByIndex(0));
                      delay(500);
                      }

                      /*

                      This sketch will display a reading in degrees centigrade on a Nokia 5110 screen

                      pinouts nokia 5111
                      1 2 3 4 5 6 7 8
                      r c d d c v l g
                      s e c i l c g n
                      t n k c t d

                      code from

                      https://www.youtube.com/watch?v=ga_1dqGjsbo

                      hacked by numbat mark

                      */


                      #include <OneWire.h>
                      #include <DallasTemperature.h>
                      #include <LCD5110_Graph.h>

                      #define ONE_WIRE_BUS 2 // it reads the digital pin

                      LCD5110 lcd(3,4,5,6,7);

                      extern unsigned char SmallFont[];
                      extern unsigned char BigNumbers[];
                      extern uint8_t temperatureIcon[];

                      char temperatureF[6];
                      char temperatureC[6];

                      OneWire oneWire(ONE_WIRE_BUS);

                      DallasTemperature sensors(&oneWire);

                      float tempC = 0;
                      float tempF = 0;

                      void setup(void)
                      {
                      lcd.InitLCD();
                      lcd.setFont(BigNumbers);
                      sensors.begin();
                      }

                      void loop(void)
                      {

                      lcd.clrScr();
                      // lcd.drawBitmap(0, 0, temperatureIcon, 84, 48);

                      sensors.requestTemperatures();

                      tempC = sensors.getTempCByIndex(0);
                      tempF = sensors.toFahrenheit(tempC);

                      // convertToString(tempF);
                      convertToString(tempC); //Uncomment this for degrees Celsius
                      // lcd.print(temperatureF,25,11);
                      lcd.print(temperatureC,25,11);

                      lcd.update();
                      delay(1000);
                      }

                      void convertToString(float number)
                      {
                      //dtostrf(number, 3, 1, temperatureF);
                      dtostrf(number, 3, 1, temperatureC);
                      }

                      • Topic 11

                        nnn

                        • Topic 12

                          nnn

                          • Topic 13

                            nnn

                            • Topic 14

                              Simple temperature measurement

                              This exercise reads the middle pin to the analogue 0 pin directly. There is no need to manipulate the voltage using a voltage dividers, reading directly does the trick. Use the serial window in your Arduino sketch application (Tools -> Serial Port) to see the results.

                              Note the use of read and readln to format the results. Using the concatenation + operator and the string "," later on means you can create output that can be read direct to a .csv file that can be read directly into a spreadsheet.

                              Also not this sensor reads in Centigrade, and the neat conversion formula to change it to Fahrenheit (for Americans).

                              Check the website for a discussion on analogReference (ahref).

                              LM 35 reference

                              /* code to read a centigrade sensor ln35dz and report 
                              to the serial window */

                              int analogPin = 0;
                              int readValue = 0;
                              float temperatureC = 0;
                              float temperatureF = 0;

                              void setup() {
                              Serial.begin(9600);
                              }

                              void loop() {
                              readValue = analogRead(analogPin);
                              //Serial.println(readValue);
                              temperatureC = (readValue * 0.0049);
                              temperatureC = temperatureC * 100;
                              temperatureF = (temperatureC * 1.8) + 32;
                              Serial.print("Temperature: ");
                              Serial.print(temperatureC);
                              Serial.print("C ");
                              Serial.print(temperatureF);
                              Serial.println("F");
                              delay(1000);
                              }


                              lm 35
                              /* using ahref to get a more accurate reading
                              */

                              float tempC;
                              int reading;
                              int tempPin = 0;

                              void setup()
                              {
                              analogReference(INTERNAL);
                              Serial.begin(9600);
                              }

                              void loop()
                              {
                              reading = analogRead(tempPin);
                              tempC = reading / 9.31;
                              Serial.println(tempC);
                              delay(1000);
                              }
                              • Topic 15

                                nnn

                                • Topic 16

                                  nnn

                                  • Topic 17

                                    • Topic 18

                                      nnn

                                      • Topic 19

                                        nnn

                                        • Topic 20

                                          nnn