Close

Grove beginner kit from Seedstudio

A few days ago I received Grove Beginner Kit ,it consist of 10 different sensor from Seedstudio in one board. It consist of an Arduino UNO compatible board (ATmega328p) and 10 sensor break out boards. It is an excellent kit for start learning programming in Arduino or even expend your programming level even more.

The advance of this board is that you have all 10 sensors in one board, already connected through i^2c protocol. This make it easy for your tests because you have not to search here and there for every sensor. If you don’t like this scenario you can of course separate each sensor just by breaking each one board. Or you can connect your sensors with cables that already included in the packet, in every pin you choose! Or you can connect your sensors for your projects, like relays, more buttons, gas sensor etc.

Links

In this link you can find the kit, bottom of the page are files like libraries and code you will need. There are also datasheet for every sensor ,documentation and some more examples. There is also a great user manual that you can find examples for all sensors and explanation for Grove Beginner Kit. Because there are many links and stuff for grove kit, if you would like to start from somewhere, i would suggest start from here.

I would like also to mention that i find really useful information and very well written in this link Grove Beginner Kit For Arduino Resources in one(20200401)[7z] .There is a folder named “More about Open-Source Hardware” and contains info and how it work about i^2c, spi, accelerometer-gyro , Can bus, l298 driver, PIR sensor,projects and more.

Code

In my code below, we will work on switch-case statement. You will also learn how to display any image you like on display or write text on it for your projects. In function SwitchStatement, run switch-case that check 4 situation from 0-3. Each case change with a button. Moreover, each case run few lines of code for example, case 1 display a string. Case 2 show the image. Case 3 scrolling text and case 4 temp-humidity. In loop function just check if button is pressed and run some code for scrolling text.

1st screen – Case 0: display a string “Hello world”
2nd screnn – Case 1:Show an image
3rd screen – Case 2: Scrolling text
4th screen – Case3:show current temperature-Humidity

How to present image on display

let’s now concentrate how to display image on a display like this. It is a 0.96″ 128X64 pixel that you use SSD1306 controller.Those types of displays bigger or smaller can display X BitMap type of format. This is a monochrome display that use U8g2lib.h (and some other) that you can find in Seedstudio documentation files. Let’s now try to make our first xbm file to load in arduino. For this, we are going to need GIMP. Gimp is a free professional image editor program.You can make our own image or download something from internet. I choose to download this image for testing. Resolution of this is 296×170 pixel.

This image is already black and white ,so we only need to resize image.Open it in GIMP and go–>Image–>Scale Image and change width to 128 and click icon on the right so that keep aspect ratio,after this height will be 74,we need 64 but it is not problem at all. Click scale and go File–>ExportAs and save it as XBM (X BitMap image). * If you have a 16 or 32 color bit image you should convert it to 1 bit. Go to image–>mode–>indexed and choose ‘Use black and white (1-bit) palette and convert. Also you can experiment with inverted colors or linear invert or value invert. Go to colors–>invert or two options below. Now,open this file with notepad and paste all those in your code but change the first line with this :

const unsigned char sound[] U8X8_PROGMEM = ......

Hard work finish, after this we call the method drawXBMP

u8g2.drawXBMP(0, 0, 128, 74, eyes);     //column, line, width, heigh, file name(eyes.xbm)

First 2 parameters are coordinates for image, it start on upper left corner, next 2 are image size as we declare it in GIMP 128×74 and the last parameter is file name. If you would like to go further more ,you can see all methods from this great library (U8g2) here and experiment with it. I wouldn’t like to go any further because it will be more advanced. You may want to check code below or download it with libraries. There are enough comments inside to help you understand how it run. I may help you in every way, good luck..

Go to Github

#include <U8g2lib.h>
#include <Arduino.h>
#include "DHT.h"

const int btnPin = 6;                             //Pin button for change cases
const int ledPin = 4;                             //Pin for led
int selector = 0;                                 //var for change cases in switch-case
DHT dht(3, DHT11);                                //temperature sensor connected to pin D3

//initialize our dipslay through i2c
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R2, /* reset=*/ U8X8_PIN_NONE);

u8g2_uint_t offset;                               // current offset for the scrolling text
u8g2_uint_t width;                                // pixel width of the scrolling text
const char *text = "Hello";                       // scroll this text from right to left

void setup() {
  u8g2.begin();                                   //initialize display
  Serial.begin(9600);
  pinMode(btnPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  u8g2.setFont(u8g2_font_inb30_mr);              // set the target font to calculate the pixel width
  width = u8g2.getUTF8Width(text);               // calculate the pixel width of the text
  u8g2.setFontMode(0);                           // enable transparent mode, which is faster
}

void loop () {                                    //loop,check if button is pressed and somde code for scrolling text

  if (digitalRead(btnPin) == HIGH ) //if button is pressed
  {
    digitalWrite(ledPin, HIGH);                  //Led on
    delay(300);
    digitalWrite(ledPin, LOW);                   //Led off
    delay(300);
    Serial.print(selector);
    SwitchStatement();                           //Call this function that incude switch-case
    selector++;                                  //switch case variable,add 1 each time btn pressed to move to next case
    if (selector > 3) {                          //When reach case 3, start from case 0(beginning)
      selector = 0;
    }
  }

  //this statement is used for Scrolling Text.Checking if Switch-Case selector is equal 3.Is so ,scroll text (case 2)
  if (selector == 3) {
    u8g2_uint_t x;
    u8g2.firstPage();
    do {                                                 // draw the scrolling text at current offset
      x =  offset;
      u8g2.setFont(u8g2_font_ncenB12_tr);        // set the target font
      do {                                       // repeated drawing of the scrolling text...
        u8g2.drawUTF8(x, 30, text);              // draw the scolling text
        x = x + (width);                         // add the pixel width of the scrolling text
      } while ( x < u8g2.getDisplayWidth() );    // draw again until the complete display is filled
    } while ( u8g2.nextPage() );
    offset -= 1;                                 // scroll by one pixel
    if ( (u8g2_uint_t)offset < (u8g2_uint_t) - width )
      offset = 0;                                // start over again
    delay(10);                                   // do some small delay
  }
}

// this is eyes.xbm made with GIMP
const unsigned char eyes[] U8X8_PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x05, 0xf4, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xbf, 0x00, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
  0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0xa0, 0xff, 0xff,
  0xff, 0xff, 0x01, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
  0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0x00, 0xa0, 0x00, 0x80, 0xff, 0xff,
  0xff, 0xff, 0x0f, 0x00, 0x52, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0xe0, 0xff,
  0x7f, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x01, 0xf8, 0xff, 0x1f, 0xc0, 0xff,
  0xff, 0x07, 0xfc, 0xff, 0xff, 0x07, 0xf8, 0xff, 0xff, 0x7f, 0x80, 0xff,
  0xff, 0xff, 0x81, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0x3f, 0xe0, 0xff,
  0xff, 0x3f, 0xf0, 0xff, 0xff, 0xff, 0x0f, 0xfe, 0xff, 0xf1, 0xff, 0xff,
  0xff, 0xff, 0xc1, 0xff, 0xff, 0x0f, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0xfe,
  0xff, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xcf, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff, 0xff, 0x77, 0xfb,
  0xbf, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf5, 0x7f, 0xfb, 0xfe, 0xff,
  0xff, 0xff, 0x7b, 0xfe, 0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff,
  0xff, 0xb9, 0xfe, 0xff, 0xff, 0xff, 0xab, 0x0e, 0x80, 0xbf, 0xff, 0xff,
  0xff, 0xff, 0xf7, 0x07, 0xc0, 0xd5, 0xfe, 0xff, 0xff, 0xff, 0xc7, 0x00,
  0x00, 0xf8, 0xfd, 0xff, 0xff, 0xff, 0xfd, 0x00, 0x00, 0x4c, 0xff, 0xff,
  0xff, 0xdf, 0xb3, 0x00, 0x00, 0xe0, 0xfb, 0xff, 0xff, 0x7f, 0x1f, 0x00,
  0x00, 0x28, 0xdf, 0xff, 0xff, 0xff, 0x2b, 0x00, 0x00, 0x80, 0xef, 0xff,
  0xff, 0xbf, 0x0f, 0x00, 0x00, 0xb0, 0xfe, 0xff, 0xff, 0x37, 0x0f, 0x0a,
  0x00, 0x00, 0xff, 0xff, 0xff, 0xdf, 0x07, 0x00, 0x80, 0xc2, 0xb5, 0xff,
  0xff, 0xef, 0x0c, 0x05, 0x00, 0x10, 0xfe, 0xff, 0xff, 0xff, 0x43, 0x00,
  0x00, 0x85, 0xb9, 0xff, 0xff, 0x0f, 0xc3, 0x0f, 0x00, 0x30, 0xfc, 0xff,
  0xff, 0xff, 0x31, 0x00, 0xc0, 0x0f, 0xc6, 0xff, 0xff, 0x7f, 0xe0, 0x1f,
  0x00, 0x60, 0xf8, 0xff, 0xff, 0xff, 0x38, 0x00, 0xc0, 0x1f, 0xe8, 0xff,
  0xff, 0x7f, 0xf1, 0x3f, 0x00, 0xe8, 0xf9, 0xff, 0xff, 0x7f, 0x7c, 0x00,
  0xe0, 0x7f, 0xf4, 0xff, 0xff, 0x7f, 0xf8, 0x3f, 0x00, 0xf0, 0xf1, 0xff,
  0xff, 0x3f, 0x5e, 0x00, 0xe0, 0xff, 0xf8, 0xff, 0xff, 0x1b, 0xfc, 0x1f,
  0x00, 0xf0, 0xe3, 0xff, 0xff, 0x3f, 0x5e, 0x00, 0xe0, 0xff, 0x60, 0xff,
  0xff, 0x03, 0xff, 0x1f, 0x00, 0xe8, 0xe7, 0xff, 0xff, 0x3f, 0x5f, 0x00,
  0xe0, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x9f, 0x03, 0xf8, 0xc7, 0xff,
  0xff, 0x9f, 0x7f, 0x00, 0xce, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x87,
  0x03, 0xe8, 0xcf, 0xff, 0xff, 0x9f, 0xff, 0x00, 0x8e, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x06, 0x01, 0xec, 0xcf, 0xff, 0xff, 0xcf, 0xbf, 0x00,
  0x04, 0xfb, 0xff, 0xff, 0xff, 0xbf, 0xff, 0x0f, 0x00, 0xfe, 0xdf, 0xff,
  0xff, 0xcf, 0xff, 0x01, 0x80, 0xff, 0xe7, 0xff, 0xff, 0x3f, 0xff, 0x1d,
  0x00, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x03, 0xc0, 0xfd, 0xe3, 0xff,
  0xff, 0x3f, 0xfc, 0x7d, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
  0xf0, 0xff, 0xf1, 0xff, 0xff, 0x7f, 0xf8, 0xfb, 0xf5, 0xfd, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x7e, 0x7f, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xf7,
  0xff, 0xfe, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xbf, 0x7f, 0xf8, 0xff,
  0xff, 0x7f, 0xe0, 0xdf, 0x7f, 0xff, 0xcf, 0xff, 0xff, 0xdf, 0xff, 0xf7,
  0xdf, 0x3f, 0xf8, 0xff, 0xff, 0xff, 0xc1, 0xbf, 0xd2, 0xff, 0xe7, 0xff,
  0xff, 0x1f, 0xff, 0x5f, 0xf2, 0x0f, 0xf4, 0xff, 0xff, 0xff, 0x0b, 0xff,
  0xff, 0xff, 0xf1, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x07, 0xff, 0xff,
  0xff, 0xff, 0x1b, 0xfe, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0xff,
  0xff, 0x41, 0xff, 0xff, 0xff, 0xff, 0x6f, 0xf8, 0xff, 0x0f, 0xff, 0xff,
  0xff, 0xff, 0xc3, 0xff, 0xff, 0xd0, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xc2,
  0xff, 0xc1, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfc, 0x1f, 0xf5, 0xff, 0xff,
  0xff, 0xff, 0xff, 0x36, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
  0xa0, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf6, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0x7f, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};

void SwitchStatement() {                          //SwitchStatement function, called in loop
  int temp = 0;                                   //int temp need for case 3
  int humid = 0;                                  //int temp need for case 3
  temp = dht.readTemperature();                   //save temperature value in temp var
  humid = dht.readHumidity();                     //save humidity value in humid var
  switch (selector) {                             //start switch-case statement

    //print Hello World
    case 0:                                       //run when selector var is equal 0, check in loop
      u8g2.firstPage();
      do {
        u8g2.drawRFrame(36, 8, 50, 25, 5);        //column,line,width,heigh,corner curve
        u8g2.setFont(u8g2_font_ncenB08_tr);
        u8g2.drawStr(45, 25, "Case 0");           //column,line,String
        u8g2.drawStr(25, 48, "Print a string");   //column,line,String
        u8g2.sendBuffer();                        //transfer arduino RAM to the display.
        Serial.print("Case ");
        Serial.print(selector);
        Serial.println(": print Hello World");
        delay(2500);
        u8g2.clearBuffer();                       //clear buffer on display
        u8g2.setFont(u8g2_font_ncenB14_tr);
        u8g2.drawStr(6, 40, "Hello World");       //column,line,String
        delay(100);
      } while (u8g2.nextPage() );
      break;

    //Show an image
    case 1:                                       //run when selector var is equal 1, check in loop
      u8g2.firstPage();
      do {
        u8g2.drawRFrame(36, 8, 50, 25, 5);        //column,line,width,heigh,corner curve
        u8g2.setFont(u8g2_font_ncenB08_tr);
        u8g2.drawStr(45, 25, "Case 1");           //column,line,String
        u8g2.drawStr(25, 48, "Show image");       //column,line,String
        u8g2.sendBuffer();                        //transfer the arduino RAM to the display.
        delay(2500);
        u8g2.clearBuffer();                       //clear buffer on display
        u8g2.setFont(u8g2_font_ncenB14_tr);
        u8g2.drawStr(0, 5, "Case 1!");            //column,line,String
        u8g2.clearBuffer();                       //clear buffer on display
        u8g2.setFont(u8g2_font_ncenB08_tr);
        u8g2.drawXBMP(0, 0, 128, 74, eyes);       //column,line,width,heigh,file name(eyes.xbm)
        u8g2.sendBuffer();                        //transfer arduino RAM to the display.
        Serial.print("Case ");
        Serial.print(selector);
        Serial.println(": print XBMP");
        delay(100);
      } while (u8g2.nextPage() );
      break;

    //Print Scrolling text, it run in loop when selector is equal 3
    case 2:                                       //run when selector var is equal 2, check in loop
      u8g2.firstPage();
      do {
        u8g2.drawRFrame(36, 8, 50, 25, 5);        //column,line,width,heigh,corner curve
        u8g2.setFont(u8g2_font_ncenB08_tr);
        u8g2.drawStr(45, 25, "Case 2");           //column,line,String
        u8g2.drawStr(25, 48, "Scrolling Text");   //column,line,String
        u8g2.sendBuffer();                        //transfer the arduino RAM to the display.
        delay(2500);
        Serial.print("Case ");
        Serial.print(selector);
        Serial.println(": print Scrolling Text");
        delay(100);
      } while (u8g2.nextPage() );
      break;

    //Print temperature,humidity
    case 3:
      u8g2.firstPage();
      do {
        u8g2.drawRFrame(36, 8, 50, 25, 5);      //column,line,width,heigh,corner curve
        u8g2.setFont(u8g2_font_ncenB08_tr);
        u8g2.drawStr(45, 25, "Case 3");         //column,line,String
        u8g2.drawStr(0, 48, "Temperature-Humidity");    //column,line,String
        u8g2.sendBuffer();                      //transfer the arduino RAM to the display.
        Serial.print("Case ");
        Serial.print(selector);
        Serial.println(": Temperature");
        delay(2500);
        u8g2.clearBuffer();                     //clear buffer on display
        u8g2.setFont(u8g2_font_t0_16b_mr);
        u8g2.setCursor(0, 18);                  //column,line for "temp"
        u8g2.print("temperature:");
        u8g2.setCursor(96, 18);                 //column,line for value temp
        u8g2.print(temp);
        u8g2.setCursor(112, 20);                //column,line for "C"
        u8g2.print("C");
        u8g2.setCursor(0, 48);                  //column,line for "humid"
        u8g2.print("humidity:");
        u8g2.setCursor(72, 48);                 //column,line for value humid
        u8g2.print(humid);
        u8g2.drawLine(0, 0, 128, 0);            //column start,line start,column stop,line stop  **  upper line
        u8g2.drawLine(0, 60, 128, 60);          //column start,line start,column stop,line stop  **  middle line
        u8g2.drawLine(25, 28, 103, 28);         //column start,line start,column stop,line stop  **  lower line
       } while (u8g2.nextPage() );
      break;
  }                                             //end switch-case statement
}  //finish SwitchStatment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2024 Electronics | WordPress Theme: Annina Free by CrestaProject.