Skip to content

12. Output devices

Group Assignment

The link to group assignment

During group assignment we have discovered and learned how to measure the current consumption of different output devices. It is necessary to know to calculate the right values for components used for PCB.

Individual Assignment

I have added LCD to my project for the previous week. It also can be related to the current week.

However, I want to describe the output device related to my final project.

There are two types of output devices that my final project will have:

  • Heating coils
  • OLED

The heating coils

There are two coils in my final project that will hot ut the ceramic chamber for herbs. Therefore, the more pov consumption of these could, and the required current is much higher than then AtMega, or AtTyny can provide. Therefore, I will use two MOSFETs to control the current.

The scheme for my project is the following.

The potentiometer here is PMW pin of AtMega.

The final demonstration you can watch in the presentation of my final project. The presentation video Link

As you can see, the coil hots up by providing current via MOSFET.

You can see how both MOSFETs located on the board.

The scheme of the board is following.

The 10K resistors between G pin and S pin of the MOSFET required according to the datasheet. It is necessary to avoid MOSFET t heating because if there is no resistor, MOSFET becomes the resistor itself.

The wire from the G pin goes to the heating coil.

In my case, I have used the MAP function to control the MOSFET. The source code you can see on my final project page.

{
   // This punction FIre Ut convection coil. It works only if the primary button is pressed.

  constrainedbuttonPushCounter = constrain(buttonPushCounter, 0, 10); // Constarain values for settings  
  ConvectPwr=map(constrainedbuttonPushCounter,0,10,0,255);
  FireButtonState = digitalRead(FireButtonPin);

  if (FireButtonState == HIGH) 
  {    // turn LED on:
  analogWrite(ConvectPin, ConvectPwr);
  } 
  else 
  {    // turn LED off:
  digitalWrite(ConvectPin, LOW);
  }  
  }

This function helps to heat the coil according to current settings. The settings can be from 0 to 10. 0 means off, and 10 means the highest temperature.

OLED

Another output device of my project is OLED. It has 128 pixels long and 32 pixels in height. I plan to show the current temperature settings of my device and let the user change the settings.

The demonstration of the functions you can find in the video. The presentation video Link

The connection of the OLED to the board is on the following picture.

You can see how it looks like when the device is on.

OLED requires external libraries to let it work with the Arduino environment.

Therefore, it is necessaery to add following libraries:

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

The whole code you can see on my final project page.

The screen allows showing information in a different format. For example, it allows showing monochrome pictures in 16-bit format.

An example of code in my project is here:

const unsigned char PROGMEM logoBmp[] = {
0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x07, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x1f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x3f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x7f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0xff, 0xef, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x01, 0xff, 0xef, 0xff, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x0f, 0xf0, 0x01, 0xfc, 0x00, 0x00, 0x00, 
0x03, 0xff, 0xcf, 0xff, 0x80, 0x00, 0x00, 0x01, 0xe0, 0x3f, 0xf8, 0x07, 0xfe, 0x00, 0x00, 0x00, 
0x03, 0xff, 0xc7, 0xff, 0x80, 0x00, 0x00, 0x03, 0xe0, 0x3f, 0xfc, 0x0f, 0xff, 0x00, 0x00, 0x00, 
0x07, 0xff, 0xc7, 0xff, 0xc0, 0x00, 0x00, 0x07, 0xe0, 0x38, 0xfe, 0x0f, 0x9f, 0x00, 0x00, 0x00, 
0x07, 0xff, 0xc7, 0xff, 0xc0, 0x00, 0x00, 0x07, 0xe0, 0x20, 0x3e, 0x1f, 0x0f, 0x80, 0x00, 0x00, 
0x0f, 0x9f, 0xc7, 0xf3, 0xc0, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x3e, 0x1e, 0x07,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0x00, 0x01, 0xf0, 0x7c, 0x00, 0x1f, 0x0f, 0x80, 0x00, 0x00, 
0x03, 0xfe, 0xec, 0xff, 0x80, 0x00, 0x00, 0x01, 0xe0, 0x7f, 0xfe, 0x1f, 0x9f, 0x00, 0x00, 0x00, 
0x01, 0xff, 0xef, 0xff, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x7f, 0xfe, 0x0f, 0xff, 0x00, 0x00, 0x00, 
0x00, 0xff, 0xef, 0xfe, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x7f, 0xfe, 0x07, 0xfe, 0x00, 0x00, 0x00,
0x00, 0x7f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x7f, 0xfe, 0x03, 0xf8, 0x00, 0x00, 0x00, 
0x00, 0x3f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x1f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

This code is the picture that you can see on the previous photo.

To create such a picture, it is necessary to open the picture editor and create a monochrome picture with the same dimensions as the screen - 128X32.

After that, it is necessary to convert the picture into a 16-bit code. You can use online-converter for this purpose. I have used website http://javl.github.io/image2cpp/ for this.

Another useful function of the screen is to show the text and numeric information.

An example of the code that I put in Void setup:

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  //initialize the screen with the interface I2C, and adress 0x3C
  display.clearDisplay(); // clear the screen
  display.drawBitmap(0, 0, logoBmp, 128, 64, WHITE); // here we show up the picture that we previously created
  display.display(); // 
  delay (2000);
  display.clearDisplay(); // clear the screen, we need to doo it every time, as the pixels continue to glow 
  display.setTextSize(1); // here wer set up the size of letters
  display.setTextColor(WHITE); // set the color scheme BW or WB
  display.setCursor(0, 0); // set the cursor X = 0; Y = 0
  display.print ("Hello, my friend!"); // remember the text
  display.setCursor(0, 10); // set the cursor X = 0; Y = 0
  display.print ("For medical use only."); // remember the text
  display.setCursor(0, 20); // уset the cursor X = 0; Y = 0
  display.print ("Stay safe!"); // remember the text
  display.display(); // show the theated text
  delay (2000);
  display.clearDisplay(); // clear the screen

The logic is simple; we create some text or graphical data, display it, and clear the screen.

In case we do not clear the screen, the glowing pixels will continue to glow, and the information on the screen will become unreadable.