The Alpha Geek – Geeking Out

Microcontrollers

Microcontrollers

Project #7: RGB LCD Shield – Rotary Switch – Mk08

Rotary Switch – 10 Position

This is a single pole, 10 position rotary switch able to select up to 10 different states in a durable package. Unlike our other rotary switch, this model is much more robust and capable of handling larger currents and voltages.

With a max voltage rating of 125VAC at 0.3A and a dielectric strength of 250VAC for 1 minute this is a serious little rotary switch capable of working with some of your bigger projects. Though this switch requires you to use 11 pins and is not breadboard friendly we do offer a breakout board (found in the Recommended Products section below) to provide easier access to its capabilities.

1 x Rotary Switch – 10 Position
1 x Hex Nut
2 x Washer

Rating: 0.3A/125VAC
Contact Resistance: 50M Ohm max
Insulation Resistance: 100M Ohm @ 500VDC min
Dielectric Strength: 250VAC for 1 minute
Rotation torque: 1.0+0.5KG/cm
Shaft: 3/8″

Rotary Switch Breakout

This is the SparkFun Rotary Switch Breakout, a very simple board designed to easily provide you access to each pin on our 10-position rotary switches. This breakout allows you to easily add a rotary switch to your next project without having to worry about attaching its unique footprint to a custom board or solderless breadboard. All you need to do is solder the 10-position rotary switch into the breakout (using the silkscreen on the board as a guide) and each pin will become available for breadboard or hookup wire compatibility.

Each one of these boards breaks out the common ( C ), 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10 positions on the board into 0.1″ spaced pins.

NeoPixel Stick – 8 x 5050 RGB LED

Make your own little LED strip arrangement with this stick of NeoPixel LEDs. We crammed 8 of the tiny 5050 (5mm x 5mm) smart RGB LEDs onto a PCB with mounting holes and a chainable design. Use only one microcontroller pin to control as many as you can chain together! Each LED is addressable as the driver chip is inside the LED. Each one has ~18mA constant current drive so the color will be very consistent even if the voltage varies, and no external choke resistors are required making the design slim. Power the whole thing with 5VDC (4-7V works) and you’re ready to rock.

DonLuc1808Mk01

1 x RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x Rotary Switch – 10 Position
1 x Rotary Switch Breakout
1 x Black Knob
1 x NeoPixel Stick – 8 x 5050 RGB LED
1 x 100K Potentiometer
1 x Black Knob
11 x 1K Ohm Resistance
17 x Jumper Wires 3″ M/M
6 x Jumper Wires 6″ M/M
1 x Size Breadboard
1 x USB Cable A to B

Arduino UNO

NEO – Digital 0
ROT – Analog 1
POT – Analog 0
GND – GND
VIN – +5V

DonLuc1808Mk01p.ino

// ***** Don Luc *****
// Software Version Information
// Project #7: RGB LCD Shield – Rotary Switch – Mk08
// 8-01
// DonLuc1808Mk01p 8-01
// RGB LCD Shield
// Rotary Switch

// Include Library Code
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <Adafruit_NeoPixel.h>

// RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
#define GREEN 0x2

// NeoPixels
#define PIN 0                             // On digital pin 3
#define NUMPIXELS 8                       // NeoPixels NUMPIXELS = 8
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int red = 0;                              // Red
int green = 0;                            // Green
int blue = 0;                             // Blue
int iNeo = 0;                             // Neopix
const int iBriPin = A0;                   // Panel Mount 1K potentiometer Brightneed
int iBri = 0;                             // Neopix Brightness
int iBriMin = 1023;                       // Brightneed minimum sensor value
int iBriMax = 0;                          // Brightneed maximun sensor value

// Rotary Switch
// Rotary Switch - 10 Position
// Number = 1 => 10
int iRotNum = A1;                         // Rotary Switch
int iVal = 0;                             // iVal - Value            
int z = 0;                                // Number

void loop() 
{

  // Rotary Switch
  isRot();

  delay(1000);
  
  // Clear
  RGBLCDShield.clear();
  
}

getRot.ino

// Rotary Switch
void isRot()
{

  // NeoPixels
  for(int y=0; y < NUMPIXELS; y++)
  { 
     // Black
     red = 0;                                 // Red
     green = 0;                               // Green
     blue = 0;                                // Blue
     iNeo = y;                                // Neopix  
     neopix();    
  }
   
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Rotary Switch");        // Rotary Switch

  // Rotary Switch
  z = analogRead( iRotNum );                  // Rotary Switch
  iVal = ( z / 100 );                         // Rotary Value
   
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iVal = ");              // Rotary Value
  RGBLCDShield.print( iVal + 1 );

  // Range Value
  switch ( iVal ) {
    case  0:
      // Red
      // NeoPixels
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 255;                           // Red
         green = 0;                           // Green
         blue = 0;                            // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      }        
      break;
    case 1:
      // Green
      // NeoPixels
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 0;                             // Red
         green = 255;                         // Green
         blue = 0;                            // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      }
      break;
    case 2:
      // Blue
      // NeoPixels
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 0;                             // Red
         green = 0;                           // Green
         blue = 255;                          // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      }
      break;
    case 3:
      // White
      // NeoPixels
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 255;                           // Red
         green = 255;                         // Green
         blue = 255;                          // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      }
      break;  
    case 4:
      // NeoPixels
      // Red
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 255;                           // Red
         green = 0;                           // Green
         blue = 0;                            // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      }
      delay( 2000 );
      // Green
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 0;                             // Red
         green = 255;                         // Green
         blue = 0;                            // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      }
      delay( 2000 );
      // Blue
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 0;                             // Red
         green = 0;                           // Green
         blue = 255;                          // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      }          
      break;
    case 5:
      // NeoPixels
      // Yellow
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 255;                           // Red
         green = 255;                         // Green
         blue = 0;                            // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      } 
      break;
    case 6:
      // NeoPixels
      // Orange
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 255;                           // Red
         green = 102;                         // Green
         blue = 0;                            // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      }
      break;       
    case 7:
      // NeoPixels
      // Violet
      for(int y=0; y<NUMPIXELS; y++){ 
         red = 204;                           // Red
         green = 102;                         // Green
         blue = 204;                          // Blue
         iNeo = y;                            // Neopix      
         neopix(); 
      }
      break; 
    case 8:
      // NeoPixels
      // Red
      red = 255;                           // Red
      green = 0;                           // Green
      blue = 0;                            // Blue
      iNeo = 0;                            // Neopix      
      neopix();
      delay( 1000 );
      // Green
      red = 0;                             // Red
      green = 255;                         // Green
      blue = 0;                            // Blue
      iNeo = 1;                            // Neopix      
      neopix();
      delay( 1000 ); 
      // Blue
      red = 0;                             // Red
      green = 0;                           // Green
      blue = 255;                          // Blue
      iNeo = 2;                            // Neopix      
      neopix();
      delay( 1000 );
      // White
      red = 255;                           // Red
      green = 255;                         // Green
      blue = 255;                          // Blue
      iNeo = 3;                            // Neopix      
      neopix();
      delay( 1000 );
      // Pink
      red = 255;                           // Red
      green = 153;                         // Green
      blue = 203;                          // Blue
      iNeo = 4;                            // Neopix      
      neopix();
      delay( 1000 );
      // Orange
      red = 255;                           // Red
      green = 102;                         // Green
      blue = 0;                            // Blue
      iNeo = 5;                            // Neopix      
      neopix();
      delay( 1000 ); 
      // Violet
      red = 204;                           // Red
      green = 102;                         // Green
      blue = 204;                          // Blue
      iNeo = 6;                            // Neopix      
      neopix();
      delay( 1000 ); 
      // Yellow
      red = 255;                           // Red
      green = 255;                         // Green
      blue = 0;                            // Blue
      iNeo = 7;                            // Neopix      
      neopix();
      delay( 1000 );         
      break; 
    case 9:
      // NeoPixels
      // Red
      red = 255;                           // Red
      green = 0;                           // Green
      blue = 0;                            // Blue
      iNeo = 7;                            // Neopix      
      neopix();
      delay( 1000 );
      // Green
      red = 0;                             // Red
      green = 255;                         // Green
      blue = 0;                            // Blue
      iNeo = 6;                            // Neopix      
      neopix();
      delay( 1000 ); 
      // Blue
      red = 0;                             // Red
      green = 0;                           // Green
      blue = 255;                          // Blue
      iNeo = 5;                            // Neopix      
      neopix();
      delay( 1000 );
      // White
      red = 255;                           // Red
      green = 255;                         // Green
      blue = 255;                          // Blue
      iNeo = 4;                            // Neopix      
      neopix();
      delay( 1000 );
      // Pink
      red = 255;                           // Red
      green = 153;                         // Green
      blue = 203;                          // Blue
      iNeo = 3;                            // Neopix      
      neopix();
      delay( 1000 );
      // Orange
      red = 255;                           // Red
      green = 102;                         // Green
      blue = 0;                            // Blue
      iNeo = 2;                            // Neopix      
      neopix();
      delay( 1000 ); 
      // Violet
      red = 204;                           // Red
      green = 102;                         // Green
      blue = 204;                          // Blue
      iNeo = 1;                            // Neopix      
      neopix();
      delay( 1000 ); 
      // Yellow
      red = 255;                           // Red
      green = 255;                         // Green
      blue = 0;                            // Blue
      iNeo = 0;                            // Neopix      
      neopix();
      delay( 1000 );
      break;
  }

}

neopix.ino

// NeoPixels
void neopix() { 
    
    // Brightness
    iBri = analogRead(iBriPin);

    // iBri apply the calibration to the sensor reading
    iBri = map(iBri, iBriMin, iBriMax, 0, 255);

    // iBri in case the sensor value is outside the range seen during calibration
    iBri = constrain(iBri, 0, 255);
    
    pixels.setBrightness( iBri );
    // Pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); 
    // This sends the updated pixel color to the hardware
    pixels.show(); 
    // Delay for a period of time (in milliseconds)
    delay(50);     
  
}

setup.ino

// Setup
void setup() 
{

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc");           // Don luc
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Rotary Switch");     // Rotary Switch
  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // NeoPixels
  pixels.begin();          // This initializes the NeoPixel library
  // NeoPixels
  
  for(int y=0; y < NUMPIXELS; y++)
  { 
     // Black
     red = 0;                                 // Red
     green = 0;                               // Green
     blue = 0;                                // Blue
     iNeo = y;                                // Neopix  
     neopix();    
  }

}

Don Luc

Project #7: RGB LCD Shield – Line Sensor Breakout – Mk07

Line Sensor Breakout – QRE1113 (Analog)

Description

This version of the QRE1113 breakout board features an easy-to-use analog output, which will vary depending on the amount of IR light reflected back to the sensor. This tiny board is perfect for line sensing applications and can be used in both 3.3V and 5V systems.

The board’s QRE1113 IR reflectance sensor is comprised of two parts – an IR emitting LED and an IR sensitive phototransistor. When you apply power to the VCC and GND pins the IR LED inside the sensor will illuminate. A 100 Ohm resistor is on-board and placed in series with the LED to limit current. A 10k Ohm resistor pulls the output pin high, but when the light from the LED is reflected back onto the phototransistor the output will begin to go lower. The more IR light sensed by the phototransistor, the lower the output voltage of the breakout board.

These sensors are widely used in line following robots – white surfaces reflect much more light than black, so, when directed towards a white surface, the voltage output will be lower than that on a black surface.

The power input and analog output pins are brought out to a 3-pin, 0.1″ pitch header. The board also has a single mounting hole if you want to screw the board onto something.

Features

* 5VDC operating voltage
* 25mA supply current
* Optimal sensing distance: 0.125″ (3mm)
* 0.30 x 0.55 “ (7.62 x 13.97 mm)

Common Reflectance Sensor

The QRE1113 is a common reflectance sensor often used in robotic line followers. The sensor works by shining an IR LED down and seeing how much of that light bounces back using a phototransistor. Because dark colors will bounce back less of the light, the sensor can be used to tell the difference between white and black areas. So an array of these can be used to help a robot determine where a dark line is on the ground so it can follow it. But they can also be used to determine proximity under an inch.

The an analog input on your microcontroller but still need an analog reading of how much light was reflected. It does this by allowing you to charge a capacitor on the board, and then timing how long it takes to discharge. The more light that is reflected, the less time it takes to discharge the capacitor. Hooking the QRE1113 to your Arduino is very simple. It just needs power (5V), ground, and an analog pin.

DonLuc1807Mk11

1 x RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x Line Sensor Breakout – QRE1113 (Analog)
3 x Jumper Wires 6″ M/M
1 x Half-Size Breadboard

Arduino UNO

CRS – Analog 0
GND – GND
VIN – +5V

DonLuc1807Mk11p.ino

// ***** Don Luc *****
// Software Version Information
// Project #7: RGB LCD Shield – Line Sensor Breakout – Mk07
// 7-11
// DonLuc1807Mk10p 7-11
// RGB LCD Shield
// QRE1113 (Analog)

// include the library code:
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
#define GREEN 0x2

// Seven-Segment Display
int iQRE1113 = A0;       // iQRE1113
int iQRE1113Value = 0;   // iQRE1113Value

void loop() 
{

  // QRE1113 (Analog)
  isCRS();

  delay(2000);
  
  // Clear
  RGBLCDShield.clear();
  
}

getSeven.ino

// Line Sensor Breakout - QRE1113
void isCRS()
{

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("QRE1113 (Analog)");       // Line Sensor Breakout - QRE1113

  iQRE1113Value = analogRead(iQRE1113);
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iQRE1113 = ");            // iQRE1113
  RGBLCDShield.print( iQRE1113Value );          // iQRE1113Value

}

setup.ino

// Setup
void setup() 
{

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc");           // Don luc
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("QRE1113 (Analog)");  // Seven-Segment Display
  delay(5000);

  // Clear
  RGBLCDShield.clear();
 
}

Don Luc

Project #7: RGB LCD Shield – Seven-Segment Display – Mk06

Seven-Segment Display

A seven-segment display (SSD), or seven-segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays.

Seven-segment displays are widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information.

Your basic 7-segment LED. Common anode. Two decimal points, but only the one on the right is wired. Digit height is 0.6″. Overall height is 1″.

Common Cathode

In a common-cathode display, the positive terminal of all the eight LEDs are connected together and then connected to iSeven2 and iSeven8. To turn on an individual segment, you ground one of the pins. The following diagram shows the internal structure of the common-cathode seven-segment display.

The internal structure of both types is nearly the same. The difference is the polarity of the LEDs and common terminal. In a common cathode seven-segment display, all seven LEDs plus a dot LED have the cathodes connected To use this display, we need to connect VIN to make the individual segments light up. The following diagram shows the internal structure of common-cathode seven-segment display.

If your Arduino application only needs to display numbers, consider using a seven-segment display. The severn-segment display has seven LEDs arranged in the shape of number eight. They are easy to use and cost effective. The picture below shows a typical seven-segment display.

DonLuc1807Mk10

1 x RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x Seven-Segment Display Red
7 x 220 ohm resistor
4 x Jumper Wires 3″ M/M
8 x Jumper Wires 6″ M/M
1 x Half-Size Breadboard

Arduino UNO

7S8 – Digital 8
7S7 – Digital 7
7S6 – Digital 6
7S5 – Digital 5
7S4 – Digital 4
7S3 – Digital 3
7S2 – Digital 2
VIN – +5V

DonLuc1807Mk10p.ino

// ***** Don Luc *****
// Software Version Information
// Project #7: RGB LCD Shield – Seven-Segment Display – Mk06
// 7-10
// DonLuc1807Mk10p 7-10
// RGB LCD Shield
// Seven-Segment Display

// include the library code:
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
#define GREEN 0x2

// Seven-Segment Display
int iSeven2 = 2;     // iSeven2
int iSeven3 = 3;     // iSeven3
int iSeven4 = 4;     // iSeven4
int iSeven5 = 5;     // iSeven5
int iSeven6 = 6;     // iSeven6
int iSeven7 = 7;     // iSeven7
int iSeven8 = 8;     // iSeven8

void loop() 
{

  // Seven-Segment Display
  isSeven();
  
  // Clear
  RGBLCDShield.clear();
  
}

getSeven.ino

// Seven-Segment Display
void isSeven()
{

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Seven-Segment");          // Seven-Segment Display
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven2 +    ");          // iSeven2 +
  digitalWrite(iSeven2, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("iSeven2 -      ");        // iSeven2 -

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven3 +    ");          // iSeven3 +
  digitalWrite(iSeven3, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("iSeven3 -      ");        // iSeven3 -

  delay(2000);
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven4 +   ");           // iSeven4 +
  digitalWrite(iSeven4, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("iSeven4 -      ");        // iSeven4 -

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven5 +   ");           // iSeven5 +
  digitalWrite(iSeven5, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("iSeven5 -      ");        // iSeven5 -  

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven6 +   ");           // iSeven6 +
  digitalWrite(iSeven6, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("iSeven6 -      ");        // iSeven6 -

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven7 +   ");           // iSeven7 +
  digitalWrite(iSeven7, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("iSeven7 -      ");        // iSeven7 -

  delay(2000);
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven8 +   ");           // iSeven8 +
  digitalWrite(iSeven8, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("iSeven8 -      ");        // iSeven8 -

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 0    ");           // iSeven 0
  digitalWrite(iSeven2, LOW);
  digitalWrite(iSeven3, LOW);
  digitalWrite(iSeven4, LOW);
  digitalWrite(iSeven5, LOW);  
  digitalWrite(iSeven6, LOW);
  digitalWrite(iSeven7, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 1    ");           // iSeven 1
  digitalWrite(iSeven3, LOW);
  digitalWrite(iSeven4, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 2    ");           // iSeven 2
  digitalWrite(iSeven2, LOW);
  digitalWrite(iSeven3, LOW);
  digitalWrite(iSeven5, LOW);  
  digitalWrite(iSeven6, LOW);
  digitalWrite(iSeven8, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 3    ");           // iSeven 3
  digitalWrite(iSeven2, LOW);
  digitalWrite(iSeven3, LOW);
  digitalWrite(iSeven4, LOW);
  digitalWrite(iSeven5, LOW);  
  digitalWrite(iSeven8, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 4    ");           // iSeven 4
  digitalWrite(iSeven3, LOW);
  digitalWrite(iSeven4, LOW);
  digitalWrite(iSeven7, LOW);
  digitalWrite(iSeven8, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 5    ");           // iSeven 5
  digitalWrite(iSeven2, LOW);
  digitalWrite(iSeven4, LOW);
  digitalWrite(iSeven5, LOW);  
  digitalWrite(iSeven7, LOW);
  digitalWrite(iSeven8, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 6    ");           // iSeven 6
  digitalWrite(iSeven2, LOW);
  digitalWrite(iSeven4, LOW);
  digitalWrite(iSeven5, LOW);  
  digitalWrite(iSeven6, LOW);
  digitalWrite(iSeven7, LOW);
  digitalWrite(iSeven8, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 7    ");           // iSeven 7
  digitalWrite(iSeven2, LOW);
  digitalWrite(iSeven3, LOW);
  digitalWrite(iSeven4, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 8    ");           // iSeven 8
  digitalWrite(iSeven2, LOW);
  digitalWrite(iSeven3, LOW);
  digitalWrite(iSeven4, LOW);
  digitalWrite(iSeven5, LOW);  
  digitalWrite(iSeven6, LOW);
  digitalWrite(iSeven7, LOW);
  digitalWrite(iSeven8, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("iSeven 9    ");           // iSeven 9
  digitalWrite(iSeven2, LOW);
  digitalWrite(iSeven3, LOW);
  digitalWrite(iSeven4, LOW);
  digitalWrite(iSeven5, LOW);  
  digitalWrite(iSeven7, LOW);
  digitalWrite(iSeven8, LOW);
  
  delay(5000);

  // Seven - Off
  isSevOff();
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven - Off    ");        // Seven - Off

  delay(2000);

}

// Seven - Off
void isSevOff()
{

  // Seven - Off
  digitalWrite(iSeven2, HIGH);
  digitalWrite(iSeven3, HIGH);
  digitalWrite(iSeven4, HIGH);
  digitalWrite(iSeven5, HIGH);  
  digitalWrite(iSeven6, HIGH);
  digitalWrite(iSeven7, HIGH);
  digitalWrite(iSeven8, HIGH);
  
}

setup.ino

// Setup
void setup() 
{

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc");           // Don luc
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Seven-Segment");     // Seven-Segment Display
  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // Seven-Segment Display
  pinMode(iSeven2, OUTPUT);                // iSeven2
  pinMode(iSeven3, OUTPUT);                // iSeven3
  pinMode(iSeven4, OUTPUT);                // iSeven4
  pinMode(iSeven5, OUTPUT);                // iSeven5
  pinMode(iSeven6, OUTPUT);                // iSeven6
  pinMode(iSeven7, OUTPUT);                // iSeven7
  pinMode(iSeven8, OUTPUT);                // iSeven8
        
  isSevOff();                              // Seven - Off
  
}

Don Luc

Project #7: RGB LCD Shield – LED RGB – Mk05

LED RGB

LED RGB are tri-color LEDs with red, green, and blue emitters, in general using a four-wire connection with one common lead (anode or cathode). These LEDs can have either common positive leads in the case of a common anode LED, or common negative leads in the case of a common cathode LED. Others, however, have only two leads (positive and negative) and have a built-in electronic control unit.

LED RGB (Red-Green-Blue) are actually three LEDs in one! But that doesn’t mean it can only make three colors. Because red, green, and blue are the additive primary colors, you can control the intensity of each to create every color of the rainbow. Most RGB LEDs have four pins: one for each color, and a common pin. On some, the common pin is the anode, and on others, it’s the cathode.

Circuit Schematics (Common Cathode)

The cathode will be connected to the VIN and will be connected through 330 Ohms resistor. We will use PWM for simulating analog output which will provide different voltage levels to the LEDs so we can get the desired colors. We will use PWM for simulating analog output which will provide different voltage levels to the LEDs so we can get the desired colors.

Source Code

I will use the pins number 4, 3 and 2 and I will name them iRed, iGreen and iBlue. In the setup section we need to define them as outputs. At the bottom of the sketch we have this custom made function named setColor() which takes 3 different arguments red, green and blue. These arguments represents the brightness of the LEDs or the duty cycle of the PWM signal which is created using the analogWrite() function. These values can vary from 0 to 255 which represents 100 % duty cycle of the PWM signal or maximum LED brightness.

So now in the loop function we will make our program which will change the color of the LED each 2 second. In order to get red light on the LED we will call the setColor() function and set value of 255 for the iRed argument and 0 for the two others. Respectively we can get the two other basic colors, green and blue.

DonLuc1807Mk09

1 x RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x LED RGB (NSTM515AS)
1 x 330 ohm resistor
4 x Jumper Wires 6″ M/M
1 x Half-Size Breadboard

Arduino UNO

Red – Digital 4
Gre – Digital 3
Blu – Digital 2
VIN – +5V

DonLuc1807Mk09p.ino

// ***** Don Luc *****
// Software Version Information
// Project #7: RGB LCD Shield – LED RGB – Mk05
// 7-9
// DonLuc1807Mk09p 7-9
// RGB LCD Shield
// LED RGB

// include the library code:
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
#define GREEN 0x2

// LED RGB
#define COMMON_ANODE
int iBlue = 2;
int iGreen = 3;
int iRed = 4;

void loop() 
{

  // LED RGB
  isColor();
   
  delay(500);
  
  // Clear
  RGBLCDShield.clear();
  
}

getColor.ino

// LED RGB
void isColor()
{

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("LED RGB");          // LED RGB
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("Red     ");         // Red
  setColor(255, 0, 0);                    // Red Color
  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("Green   ");         // Green
  setColor(0, 255, 0);                    // Green Color
  
  delay(2000);

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1); 
  RGBLCDShield.print("Blue   ");          // Blue
  setColor(0, 0, 255);                    // Blue Color
  delay(2000);
  
}

void setColor(int red, int green, int blue) 
{

  #ifdef COMMON_ANODE
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
  #endif

  analogWrite(iRed, red);
  analogWrite(iGreen, green);
  analogWrite(iBlue, blue);

}

setup.ino

// Setup
void setup() 
{

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc");         // Don luc
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("LED RGB");         // LED RGB

  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // LED RGB
  pinMode(iBlue, OUTPUT);                 // Blue
  pinMode(iGreen, OUTPUT);                // Green
  pinMode(iRed, OUTPUT);                  // Red

}

Don Luc

Project #7: RGB LCD Shield – IR Emitters and Detectors – Mk04

Infrared Emitters and Detectors

Side-looking Infrared Emitters and IR Detectors. These simple devices operate at 940nm and work well for generic IR systems including remote control and touch-less object sensing. Using a simple ADC on any microcontroller will allow variable readings to be collected from the detector. The emitter is driven up to 50mA with a current limiting resistor as with any LED device. The detect is a NPN transistor that is biased by incoming IR light.

Sold as a pair, with one Emitter and one Detector.

IR Emitter

Connect IR LED using a 270 ohm series resistor to the +5 supply (or to an Arduino pin if you want to switch the source on and off). Current draw is about 11 mA with a 270 ohm resistor. Current runs from anode to cathode. Flat on the case marks the cathode. To determine if the IR LED is the right way around.

IR Detector

A IR Detector is just like a regular transistor except the base lead is disabled or absent and light activates base current. The flat on the case marks the collector, the other lead is the emitter. Connect the collector to one end of a 10K ohm resistor and connect the other end of the resistor to a +5V supply (you can use the +5 pin on the Arduino). Connect the emitter to ground. The voltage should start out at +5V. When pointing the IR Detector, the voltage should drop down to near zero. To interface with the Arduino, make a second connection from the collector to an Arduino pin.

DonLuc1807Mk08

1 x RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x IR Emitter
1 x IR Detector
1 x 270 ohm resistor
1 x 10k ohm resistor
3 x Jumper Wires 3″ M/M
4 x Jumper Wires 6″ M/M
1 x Half-Size Breadboard

Arduino UNO

Det – Analog A0
Emi – Digital 2
VIN – +5V
GND – GND

DonLuc1807Mk08p.ino

// ***** Don Luc *****
// Software Version Information
// Project #7: RGB LCD Shield – IR Emitters and Detectors – Mk04
// 7-8
// DonLuc1807Mk08p 7-8
// RGB LCD Shield
// IR Emitters and Detectors

// include the library code:
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
#define GREEN 0x2

// IR Emitters and Detectors
int iDet = 2;
int iSense = A0;
int iVal;

void loop() 
{

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("IR Emi - Det");     // IR Emitters and Detectors
  
  // IR Emitters and Detectors
  iVal = analogRead(iSense);
  
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  if ( iVal >= 1005 ) 
  {
     RGBLCDShield.print("Alarm");         // Alarm    
  }
  else
  {
     RGBLCDShield.print("No");            // No
  }
  
  delay(1000);
  
  // Clear
  RGBLCDShield.clear();
  
}

setup.ino

// Setup
void setup() 
{

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc");         // Don luc
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("IR Emi - Det");    // IR Emitters and Detectors

  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // IR Emitters and Detectors
  pinMode(iDet, OUTPUT);
  pinMode(iSense, INPUT);
  digitalWrite(iDet,HIGH);

}

Don Luc

Project #9: Stepper – EasyDriver – Mk04

EasyDriver – Hook-Up

Once you have all the headers soldered on, it’s time to hook up the EasyDriver to your Arduino. Using the picture below, make all the necessary connections.

Note: The small stepper motor looks different than the one pictured. It should have a 4-pin connector on the end. This will be attached to the 4-pin male header facing upward. Because of the nature of this particular stepper, you can hook up the connector in either orientation, i.e. either the black wire on the left or the yellow wire on the left. It will work either way. If you are using a different motor, consult its documentation to find out which wires should go where.

IMPORTANT: Stepper motors require more power than can be supplied by the Arduino. In this example we will be powering the Uno with a 12V external supply. Notice that the power input (M+) on the EasyDriver is attached to the Vin pin on the Arduino. This will allow you to power both the Arduino and the motor with the same power supply.

DonLuc1807Mk07

1 x RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x EasyDriver
1 x Small Stepper Motor
1 x Pololu Mounting
3 x Jumper Wires 3″ M/M
4 x Jumper Wires 6″ M/M
1 x Half-Size Breadboard

Arduino UNO

Spe – Digital 3
Dir – Digital 2
VIN – +5V
GND – GND

DonLuc1807Mk07p.ino

// ***** Don Luc *****
// Software Version Information
// Project #9: Stepper - EasyDriver - Mk04
// 7-7
// DonLuc1807Mk07p 7-7
// Stepper
// EasyDriver

// include the library code:
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
#define GREEN 0x2

// EasyDriver
int dirPin = 2;                           // EasyDriver
int stepPin = 3;                          // stepPin

void loop() {

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("EasyDriver");       // EasyDriver
  
  // EasyDriver
  int i;

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Left");             // Left
  
  digitalWrite(dirPin, LOW);              // Set the direction.
  delay(100);

  for (i = 0; i<4000; i++)                // Iterate for 4000 microsteps.
  {
    digitalWrite(stepPin, LOW);           // This LOW to HIGH change is what creates the
    digitalWrite(stepPin, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
    delayMicroseconds(500);               // This delay time is close to top speed for this
  }                                       // particular motor. Any faster the motor stalls.

  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Right");            // Right
  
  digitalWrite(dirPin, HIGH);             // Change direction.
  delay(2000);

  for (i = 0; i<4000; i++)                // Iterate for 4000 microsteps
  {
    digitalWrite(stepPin, LOW);           // This LOW to HIGH change is what creates the
    digitalWrite(stepPin, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
    delayMicroseconds(500);               // This delay time is close to top speed for this
  }                                       // particular motor. Any faster the motor stalls.

  delay(2000);
  
  // Clear
  RGBLCDShield.clear();
  
}

setup.ino

// Setup
void setup() {

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc");         // Don luc
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("EasyDriver");      // EasyDriver

  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // EasyDriver
  pinMode(dirPin, OUTPUT);
  pinMode(stepPin, OUTPUT);

}

Don Luc

Project #8: Servo – Potentiometer Servo – Mk01

Servo Motor

A servo motor is a rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity and acceleration. It consists of a suitable motor coupled to a sensor for position feedback. It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use with servo motors.

Servo motors have been around for a long time and are utilized in many applications. They are small in size but pack a big punch and are very energy-efficient. These features allow them to be used to operate remote-controlled or radio-controlled toy cars, robots and airplanes. Servo motors are also used in industrial applications, robotics, in-line manufacturing, pharmaceutics and food services.

Circuit

Servo motors have three wires: power, ground, and signal. The power wire is red, and should be connected to the 5V pin on the Arduino board. The ground wire is black and should be connected to a ground pin on the board. The signal pin is orange and should be connected to pin 9 on the board.

The potentiometer should be wired so that its two outer pins are connected to power (+5V) and ground, and its middle pin is connected to analog input 0 on the board.

DonLuc1805Mk07

1 x RGB LCD Shield 16×2 Character Display
1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x Servo Motor
1 x 100k Ohm Potentiometer
1 x Potentiometer Knob
4 x Jumper Wires 3″ M/M
4 x Jumper Wires 6″ M/M
1 x Half-Size Breadboard

Arduino UNO

Ser – Digital 9
Pot – Analog A0
VIN – +5V
GND – GND

DonLuc1807Mk03.ino

// ***** Don Luc *****
// Software Version Information
// Project #8: Servo Motor - Potentiometer - Mk01
// 7-3
// DonLuc1807Mk03 7-3
// Servo Motor
// Potentiometer Servo

// include the library code:
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <Servo.h>

Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
#define GREEN 0x2

// Potentiometer Servo Motor
Servo isServo;                            // Create servo object to control a servo
int iPot1 = A0;                           // Analog Potentiometer 1
int iVal;                                 // Variable - Analog Potentiometer 1

void loop() {

  // Potentiometer Servo Motor
  iVal = analogRead(iPot1);               // Reads the value of the iPot1 (Value between 0 and 1023)
  iVal = map(iVal, 0, 1023, 0, 180);      // Scale it to use it with the isServo (Value between 0 and 180)
  isServo.write(iVal);                    // isServo sets the servo position according to the scaled value
  delay(15);    

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Potentiometer");     // Potentiometer
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print(iVal);                // Reads the value iVal
  
  delay(500);
  
  // Clear
  RGBLCDShield.clear();
  
}

setup.ino

// Setup
void setup() {

  // set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc");         // Don luc
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Potentiometer");   // Potentiometer Servo Motor

  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // Potentiometer Servo Motor
  isServo.attach(9);                     // Attaches the Servo on pin 9 to the Servo Object

}

Don Luc

Project #6: MicroView – Alcohol Gas Sensor – Mk09

Alcohol Gas Sensor – MQ-3

This alcohol sensor is suitable for detecting alcohol concentration on your breath, just like your common breathalyzer. It has a high sensitivity and fast response time. Sensor provides an analog resistive output based on alcohol concentration. The drive circuit is very simple, all it needs is one resistor. A simple interface could be a 0-3.3V ADC.

Features

* 5V DC or AC circuit
* Requires heater voltage
* Operation Temperature: -10 to 70 degrees C
* Heater consumption: less than 750mW* 16.8mm diameter
* 9.3 mm height without the pins

Note: Again, the MQ-3 is heater-driven so be aware that the sensor will become warm and may even emit a smell at first. This is completely normal.

Calibration: If you take your time, you can find out what values equate to specific percentages or even blood alcohol concentration in the case of a breathalyzer. You will of course need to calibrate your MQ-3 based on your specific Arduino code since sensor readings will vary. Do not get the sensor wet with alcohol! Simply squeeze to breathe the vapors of the alcohol into the sensor and take your readings.

Alcohol Gas Sensor – MQ-3

1 x MicroView
1 x MicroView – USB Programmer
1 x Alcohol Gas Sensor – MQ-3
1 x NeoPixel Stick – 8 x 5050 RGB LED
1 x LED Green
1 x 10k Ohm
1 x 100k Ohm Potentiometer
1 x Potentiometer Knob
1 x 4 Header
2 x 2 Header
14 x Jumper Wires 3″ M/M
1 x Half-Size Breadboard
1 x Battery Holder 3xAAA with Cover and Switch
3 x Battery AAA

MicroView

Pot – PIN 05 – Analog A2
MQ-3 – PIN 07 – Analog A0
GND – PIN 08 – GND
VIN – PIN 15 – +5V
NEO – PIN 12 – Digital 3
LEDG – PIN 11 – Digital 2

DonLuc1807Mk01

DonLuc1807Mk01.ino

// ***** Don Luc *****
// Software Version Information
// Project #6: MicroView - Alcohol Gas Sensor - MQ-3 - Mk09
// 7.1
// DonLuc1807Mk01 7-1
// MicroView
// Alcohol Gas Sensor - MQ-3

// include the library code:
#include <MicroView.h>
#include <Adafruit_NeoPixel.h>

// Alcohol Gas Sensor - MQ-3
int mq3Pin0 = A0;                         // Connected to the output pin of MQ3 
int mq3Value = 0;

// NeoPixels
#define PIN 3                             // On digital pin 3
#define NUMPIXELS 8                       // NeoPixels NUMPIXELS = 8
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int red = 0;                              // Red
int green = 0;                            // Green
int blue = 0;                             // Blue
int iNeo = 0;                             // Neopix
const int iBriPin = A2;                   // Panel Mount 1K potentiometer Brightneed
int iBri = 0;                             // Neopix Brightness
int iBriMin = 1023;                       // Brightneed minimum sensor value
int iBriMax = 0;                          // Brightneed maximum sensor value

// LED
int ledG = 1;                             // LED Green

void loop() {
  
  // Alcohol Gas Sensor - MQ-3
  // Give ample warmup time for readings to stabilize
  isMQ3();

  delay(100);
  
  uView.clear(PAGE);  // Erase the memory buffer, the OLED will be cleared
  
}

getMQ3.ino

// Alcohol Gas Sensor - MQ-3
void isMQ3(){

  // LEDs - Low
  for(int z=0; z<NUMPIXELS; z++){ 
     // Black
     red = 0;                                 // Red
     green = 0;                               // Green
     blue = 0;                                // Blue
     iNeo = z;                                // Neopix       
     neopix(); 
  }
    
  // Probe
  mq3Value = analogRead(mq3Pin0);              // Take a reading from the probe
  
  if( mq3Value >= 1 ){                         // If the reading isn't zero, proceed
    
    if (mq3Value > 1){                         // If the average is over 50 ...
      // Green
      red = 0;                                 // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 0;                                // Neopix       
      neopix();      
    }
    else{                                      // and if it's not ...
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 0;                                // Neopix        
      neopix();      
    }

    if (mq3Value > 250){                        // and so on ...
      // Green
      red = 0;                                 // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 1;                                // Neopix       
      neopix();
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 1;                                // Neopix        
      neopix(); 
    }

    if (mq3Value > 350){
      // Green
      red = 0;                                 // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 2;                                // Neopix       
      neopix();
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 1;                                // Neopix        
      neopix(); 
    }


    if (mq3Value > 500){
      // Yellow
      red = 255;                               // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 3;                                // Neopix
      neopix();
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 3;                                // Neopix       
      neopix(); 
    }

    if (mq3Value > 650){
      // Yellow
      red = 255;                               // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 4;                                // Neopix      
      neopix();
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 4;                                // Neopix        
      neopix(); 
    }

    if (mq3Value > 750){
      // Yellow
      red = 255;                               // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 5;                                // Neopix  
      neopix();
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 5;                                // Neopix        
      neopix(); 
    }

    if (mq3Value > 850){
      // Red
      red = 255;                               // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 6;                                // Neopix       
      neopix();
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 6;                                // Neopix       
      neopix();
    }

    if (mq3Value > 950){
      // Red
      red = 255;                               // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 7;                                // Neopix      
      neopix();
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 7;                                // Neopix        
      neopix();
    }

  }
  
  uView.setFontType(0);  // Set font type 0: Numbers and letters. 10 characters per line (6 lines)

  uView.setCursor(0,10); // Alcohol Gas Sensor
  uView.print( "Alcohol" );
  uView.setCursor(0,30); // Alcohol Gas Sensor
  uView.print( mq3Value ); 
        
  uView.display();       // Display
   
}

neopix.ino

// Neopix
void neopix() { 

    // Brightness
    iBri = analogRead(iBriPin);

    // iBri apply the calibration to the sensor reading
    iBri = map(iBri, iBriMin, iBriMax, 0, 255);

    // iBri in case the sensor value is outside the range seen during calibration
    iBri = constrain(iBri, 0, 255);  
    
    pixels.setBrightness( iBri );
    // Pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); 
    // This sends the updated pixel color to the hardware
    pixels.show(); 
    // Delay for a period of time (in milliseconds)
    delay(50);     
  
}

setup.ino

// Setup
void setup() {

  uView.begin();           // Begin of MicroView
  uView.clear(ALL);        // Erase hardware memory inside the OLED controller
  uView.display();         // Display the content in the buffer memory, by default it is the MicroView logo
  
  delay(1000);
  
  uView.clear(PAGE);       // Erase the memory buffer, the OLED will be cleared.
   
  uView.setFontType(1);    // Set font type 1: Numbers and letters. 7 characters per line (3 lines)
  uView.setCursor(0,20);
  uView.print("Don Luc");  // Don Luc
  uView.display();         // Display
  
  delay(5000);

  uView.clear(PAGE);       // Erase the memory buffer, the OLED will be cleared.

  uView.setFontType(1);    // Set font type 1: Numbers and letters. 7 characters per line (3 lines)
  uView.setCursor(0,20);
  uView.print("MQ-3");     // Alcohol Gas Sensor - MQ-3
  uView.display();         // Display 
  
  delay(5000);
  
  uView.clear(PAGE);       // Erase the memory buffer, the OLED will be cleared

  // NeoPixels
  pixels.begin();          // This initializes the NeoPixel library

  // LED
  pinMode( ledG, OUTPUT ); // LED Green 
  // LED Green - High 
  digitalWrite( ledG, HIGH);
       
}

Don Luc

Raspberry Pi NoIR Camera V2.1

The infrared Camera Module v2 (Pi NoIR) has a Sony IMX219 8-megapixel sensor custom designed add-on board for Raspberry Pi, featuring a fixed focus lens. It’s capable of 3280 x 2464 pixel static images, and also support 1080p30, 720p60, and 640x480p60/90 video. The Pi NoIR gives you everything the regular Camera Module offers, with one difference: it does not employ an infrared filter. This means that pictures you take by daylight will look decidedly curious, but it gives you the ability to see in the dark with infrared lighting.

We bundle a little square of blue gel with the Pi NoIR “night vision”, which you can use with the camera to monitor the health of green plants. The Pi NoIR is very popular among wildlife hobbyists: with a few infrared LEDs, you can monitor what nocturnal animals are doing in your garden without disturbing them. It attaches to the Pi by way of one of the small sockets on the board’s upper surface and uses the dedicated CSi interface, designed especially for interfacing to cameras. The NoIR Camera has No InfraRed (NoIR) filter on the lens which makes it perfect for doing Infrared photography and taking pictures in low light (twilight) environments.

Features

Improved Resolution

* 8 megapixel native resolution high quality Sony IMX219 image sensor
* Cameras are capable of 3280 x 2464 pixel static images

Remaining High Quality

* Capture video at 1080p30, 720p60 and 640x480p90 resolutions
* All software is supported within the latest version of Raspbian Operating System
* No Infrared filter making it perfect for taking Infrared photographs or photographing objects in low light (twilight) conditions
* 1.4 µm X 1.4 µm pixel with OmniBSI technology for high performance (high sensitivity, low crosstalk, low noise)
* Optical size of 1/4″

Technical Details

Dimensions: 25mm x 23mm x 9mm / 0.98″ x 0.90″ x 0.35″
Weight (camera board + attached cable): 3.4g

1 x Raspberry Pi NoIR Camera V2.1
1 x Filter
1 x Camera Cable
1 x Raspberry Pi 3 – Model B
1 x MicroSD 16 GB
1 x 5V 2A Switching Power Supply

Don Luc

Project #6: MicroView – EMF Meter (Single Axis) – Mk08

Electromagnetic Field

An electromagnetic field (also EMF or EM field) is a physical field produced by electrically charged objects. It affects the behavior of charged objects in the vicinity of the field. The electromagnetic field extends indefinitely throughout space and describes the electromagnetic interaction. It is one of the four fundamental forces of nature (the others are gravitation, weak interaction and strong interaction).

The field can be viewed as the combination of an electric field and a magnetic field. The electric field is produced by stationary charges, and the magnetic field by moving charges (currents); these two are often described as the sources of the field. The way in which charges and currents interact with the electromagnetic field is described by Maxwell’s equations and the Lorentz force law. The force created by the electric field is much stronger than the force created by the magnetic field.

From a classical perspective in the history of electromagnetism, the electromagnetic field can be regarded as a smooth, continuous field, propagated in a wavelike manner; whereas from the perspective of quantum field theory, the field is seen as quantized, being composed of individual particles.

EMF Measurement

EMF measurements are measurements of ambient (surrounding) electromagnetic fields that are performed using particular sensors or probes, such as EMF meters. These probes can be generally considered as antennas although with different characteristics. In fact probes should not perturb the electromagnetic field and must prevent coupling and reflection as much as possible in order to obtain precise results. There are two main types of EMF measurements:

* Broadband measurements performed using a broadband probe, that is a device which senses any signal across a wide range of frequencies and is usually made with three independent diode detectors;
* Frequency selective measurements in which the measurement system consists of a field antenna and a frequency selective receiver or spectrum analyzer allowing to monitor the frequency range of interest.

EMF probes may respond to fields only on one axis, or may be tri-axial, showing components of the field in three directions at once. Amplified, active, probes can improve measurement precision and sensitivity but their active components may limit their speed of response.

EMF Meters

An EMF meter is a scientific instrument for measuring electromagnetic fields (abbreviated as EMF). Most meters measure the electromagnetic radiation flux density (DC fields) or the change in an electromagnetic field over time (AC fields), essentially the same as a radio antenna, but with quite different detection characteristics.

The two largest categories are single axis and tri-axis. Single axis meters are cheaper than tri-axis meters, but take longer to complete a survey because the meter only measures one dimension of the field. Single axis instruments have to be tilted and turned on all three axes to obtain a full measurement. A tri-axis meter measures all three axes simultaneously, but these models tend to be more expensive.

Electromagnetic fields can be generated by AC or DC currents. An EMF meter can measure AC electromagnetic fields, which are usually emitted from man-made sources such as electrical wiring, while gaussmeters or magnetometers measure DC fields, which occur naturally in Earth’s geomagnetic field and are emitted from other sources where direct current is present.

EMF Meter (Single Axis)

1 x MicroView
1 x MicroView – USB Programmer
1 x DS18S20
1 x NeoPixel Stick – 8 x 5050 RGB LED
1 x Speaker
1 x LED Red
1 x LED Green
1 x LED Yellow
1 x 330 Ohm
1 x 1.5k Ohm
1 x 3.3M Ohm
1 x 3″ Wire Solid Core, 22 AWG
1 x 4 Header
20 x Jumper Wires 3″ M/M
1 x Half-Size Breadboard
1 x Battery Holder 3xAAA with Cover and Switch
3 x Battery AAA

MicroView

WIRE – PIN 02 – Analog A5
GND – PIN 08 – GND
VIN – PIN 15 – +5V
TEM – PIN 14 – Digital 5
SPE – PIN 13 – Digital 4
NEO – PIN 12 – Digital 3
LEDG – PIN 11 – Digital 2
LEDY – PIN 10 – Digital 1
LEDR – PIN 09 – Digital 0

DonLuc1806Mk01

DonLuc1806Mk01a.ino

// ***** Don Luc *****
// Software Version Information
// Project #6: MicroView - EMF Meter (Single Axis) - Mk08
// 6.1
// DonLuc1806Mk01 6-1
// MicroView
// EMF Meter (Single Axis)

// include the library code:
#include <MicroView.h>
#include <Adafruit_NeoPixel.h>
// Pitches
#include "pitches.h"
#include <OneWire.h>

// EMF Meter (Single Axis)
#define NUMREADINGS 15                    // Raise this number to increase data smoothing
int senseLimit = 15;                      // Raise this number to decrease sensitivity (up to 1023 max)
int val = 0;                              // Val
int iEMF = A5;                            // EMF Meter
int readings[ NUMREADINGS ];              // Readings from the analog input
int index = 0;                            // Index of the current reading
int total = 0;                            // Running total
int average = 0;                          // Final average of the probe reading
// NeoPixels
#define PIN 3                             // On digital pin 3
#define NUMPIXELS 8                       // NeoPixels NUMPIXELS = 8
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int red = 0;                              // Red
int green = 0;                            // Green
int blue = 0;                             // Blue
int iNeo = 0;                             // Neopix
int iBri = 0;                             // Neopix Brightness
// LED
int ledR = 0;                             // LED Red
int ledG = 1;                             // LED Green
int ledY = 2;                             // LED Yellow
// 8-ohm speaker
#define tonePIN 5                         // On digital pin 5
// Temperature chip i/o
int DS18S20_Pin = 6;                      // DS18S20 Signal pin on digital 6
OneWire ds(DS18S20_Pin);                  // On digital pin 6
float temperature = 0;                    // Temperature

void loop() {
  
  // EMF Meter (Single Axis)
  isEMF();

  delay(250);
  
  uView.clear(PAGE);  // Erase the memory buffer, the OLED will be cleared
  
}

getEMF.ino

// EMF Meter (Single Axis)
void isEMF(){

  // LEDs - Low
  for(int z=0; z<NUMPIXELS; z++){ 
     // Black
     red = 0;                                 // Red
     green = 0;                               // Green
     blue = 0;                                // Blue
     iNeo = z;                                // Neopix
     iBri = 0;                                // Neopix Brightness        
     neopix(); 
  }
  digitalWrite(ledG, LOW);                    // Turn that LED off
  digitalWrite(ledY, LOW);                    // Turn that LED off  
  noTone(tonePIN);                            // noTone
    
  // Probe
  val = analogRead( iEMF );                    // Take a reading from the probe
  
  if( val >= 1 ){                              // If the reading isn't zero, proceed

    val = constrain( val, 1, senseLimit );     // Turn any reading higher than the senseLimit value into the senseLimit value
    val = map( val, 1, senseLimit, 1, 1023 );  // Remap the constrained value within a 1 to 1023 range

    total -= readings[ index ];                // Subtract the last reading
    readings[ index ] = val;                   // Read from the sensor
    total += readings[ index ];                // Add the reading to the total
    index = ( index + 1 );                     // Advance to the next index

    if ( index >= NUMREADINGS ) {              // If we're at the end of the array...
      index = 0;                               // ...wrap around to the beginning
    }  

    average = total / NUMREADINGS;             // Calculate the average

    if (average < 50) {                        // If the average is less 50 ...
      digitalWrite(ledG, HIGH);                // turn that LED On  
      tone(tonePIN, NOTE_C3);                  // Tone         
    }
    else{                                      // and if it's not ...
      digitalWrite(ledG, LOW);                 // turn that LED off
      noTone(tonePIN);                         // noTone
    }
    
    if (average > 50){                         // If the average is over 50 ...
      // Green
      red = 0;                                 // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 0;                                // Neopix
      iBri = 100;                              // Neopix Brightness        
      neopix();      
      tone(tonePIN, NOTE_C4);                  // Tone
    }
    else{                                      // and if it's not ...
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 0;                                // Neopix
      iBri = 0;                                // Neopix Brightness        
      neopix();      
      noTone(tonePIN);                         // noTone
    }

    if (average > 250){                        // and so on ...
      // Green
      red = 0;                                 // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 1;                                // Neopix
      iBri = 100;                              // Neopix Brightness        
      neopix();
      tone(tonePIN, NOTE_D4);                  // Tone
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 1;                                // Neopix
      iBri = 0;                                // Neopix Brightness        
      neopix(); 
      noTone(tonePIN);                         // noTone
    }

    if (average > 350){
      // Green
      red = 0;                                 // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 2;                                // Neopix
      iBri = 100;                              // Neopix Brightness        
      neopix();
      tone(tonePIN, NOTE_E4);                  // Tone
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 1;                                // Neopix
      iBri = 0;                                // Neopix Brightness        
      neopix(); 
      noTone(tonePIN);                         // noTone
    }


    if (average > 500){
      // Yellow
      red = 255;                               // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 3;                                // Neopix
      iBri = 100;                              // Neopix Brightness        
      neopix();
      tone(tonePIN, NOTE_F4);                  // Tone
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 3;                                // Neopix
      iBri = 0;                                // Neopix Brightness        
      neopix(); 
      noTone(tonePIN);                         // noTone
    }

    if (average > 650){
      // Yellow
      red = 255;                               // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 4;                                // Neopix
      iBri = 100;                              // Neopix Brightness        
      neopix();
      tone(tonePIN, NOTE_G4);                  // Tone
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 4;                                // Neopix
      iBri = 0;                                // Neopix Brightness        
      neopix(); 
      noTone(tonePIN);                         // noTone
    }

    if (average > 750){
      // Yellow
      red = 255;                               // Red
      green = 255;                             // Green
      blue = 0;                                // Blue
      iNeo = 5;                                // Neopix
      iBri = 100;                              // Neopix Brightness        
      neopix();
      tone(tonePIN, NOTE_A4);                  // Tone
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 5;                                // Neopix
      iBri = 0;                                // Neopix Brightness        
      neopix();
      noTone(tonePIN);                         // noTone 
    }

    if (average > 850){
      // Red
      red = 255;                               // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 6;                                // Neopix
      iBri = 100;                              // Neopix Brightness        
      neopix();
      tone(tonePIN, NOTE_B4);                  // Tone
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 6;                                // Neopix
      iBri = 0;                                // Neopix Brightness        
      neopix();
      noTone(tonePIN);                         // noTone 
    }

    if (average > 950){
      // Red
      red = 255;                               // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 7;                                // Neopix
      iBri = 100;                              // Neopix Brightness        
      neopix();
      tone(tonePIN, NOTE_C5);                  // Tone
    }
    else{
      // Black
      red = 0;                                 // Red
      green = 0;                               // Green
      blue = 0;                                // Blue
      iNeo = 7;                                // Neopix
      iBri = 0;                                // Neopix Brightness        
      neopix();
      noTone(tonePIN);                         // noTone 
    }

  }
  else
  {

    digitalWrite(ledY, HIGH);                  // turn that LED On     
    noTone(tonePIN);                           // noTone
    
  }
  
  uView.setFontType(0);  // Set font type 0: Numbers and letters. 10 characters per line (6 lines)

  uView.setCursor(0,10); // EMF Meter
  uView.print( "EMF: " );
  uView.print( average ); 

  // Temperature chip i/o
  isTe();
        
  uView.display();       // Display
   
}

getTemperature.ino

// Temperature chip i/o
void isTe() {

  // Temperature chip i/o
  temperature = getTemp();
  
  uView.setCursor(0,30);  
  uView.print(temperature);
  uView.print(" *C");

}

float getTemp() {
  
  // Returns the temperature from one DS18S20 in DEG Celsius
  byte data[12];
  byte addr[8];
 
  if ( !ds.search(addr)) {
      // No more sensors on chain, reset search
      ds.reset_search();
      return -1001;
  }
 
  if ( OneWire::crc8( addr, 7) != addr[7]) {
      return -1002;
  }
 
  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      return -1003;
  }
 
  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);                           // Start conversion, with parasite power on at the end
 
  byte present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);                             // Read Scratchpad
 
  
  for (int i = 0; i < 9; i++) {               // we need 9 bytes
    data[i] = ds.read();
  }
  
  ds.reset_search();
  
  byte MSB = data[1];
  byte LSB = data[0];
 
  float tempRead = ((MSB << 8) | LSB);        // Using two's compliment
  float TemperatureSum = tempRead / 16;
  
  return TemperatureSum;
 
}

neopix.ino

void neopix() { 
    
    // Brightness
    pixels.setBrightness( iBri );
    // Pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); 
    // This sends the updated pixel color to the hardware
    pixels.show(); 
    // Delay for a period of time (in milliseconds)
    delay(50);     
  
}

pitches.h

/*************************************************
 * Public Constants
 *************************************************/
 
// Note
#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978

setup.ino

void setup() {

  uView.begin();           // Begin of MicroView
  uView.clear(ALL);        // Erase hardware memory inside the OLED controller
  uView.display();         // Display the content in the buffer memory, by default it is the MicroView logo
  
  delay(1000);
  
  uView.clear(PAGE);       // Erase the memory buffer, the OLED will be cleared.
   
  uView.setFontType(1);    // Set font type 1: Numbers and letters. 7 characters per line (3 lines)
  uView.setCursor(0,20);
  uView.print("Don Luc");  // Don Luc
  uView.display();         // Display
  
  delay(5000);

  uView.clear(PAGE);       // Erase the memory buffer, the OLED will be cleared.

  uView.setFontType(1);    // Set font type 1: Numbers and letters. 7 characters per line (3 lines)
  uView.setCursor(0,20);
  uView.print("EMF Met");  // EMF Meter (Single Axis)
  uView.display();         // Display 
  
  delay(5000);
  
  uView.clear(PAGE);       // Erase the memory buffer, the OLED will be cleared

  // NeoPixels
  pixels.begin();          // This initializes the NeoPixel library
  // EMF Meter (Single Axis)
  pinMode( iEMF, OUTPUT ); // EMF Meter
  for (int i = 0; i < NUMREADINGS; i++){
    readings[ i ] = 0;     // Initialize all the readings to 0
  }
  // LED
  pinMode( ledR, OUTPUT ); // LED Red
  pinMode( ledG, OUTPUT ); // LED Green
  pinMode( ledY, OUTPUT ); // LED Yellow 
  // LED Red - High 
  digitalWrite( ledR, HIGH);
       
}

Don Luc

Categories
Archives