Luc Paquin
Published © CC BY

Project #14: Components - Laser Pointer - Mk22

Project #14: Components - Laser Pointer - Mk22

BeginnerFull instructions provided1 hour16
Project #14: Components - Laser Pointer - Mk22

Things used in this project

Hardware components

Elecrow Crowduino Uno - SD
×1
Elecrow Crowtail - Base Shield
×1
Elecrow Crowtail - I2C LCD
×1
Elecrow Crowtail - Laser Pointer 2.0
×1
Elecrow Crowtail - Switch
×1
Elecrow Crowtail - LED(Green)
×1
USB Battery Pack
×1
SparkFun USB Mini-B Cable - 6 Foot
SparkFun USB Mini-B Cable - 6 Foot
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Fritzing

Code

DL2507Mk02p.ino

Arduino
/****** Don Luc Electronics © ******
Software Version Information
Project #14: Components - Laser Pointer - Mk22
DL2507Mk02p.ino
DL2507Mk02
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - I2C LCD
1 x Crowtail - Laser Pointer 2.0
1 x Crowtail - Switch
1 x Crowtail - LED(Green)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"

// Laser Pointer
int iLaserPointer = 5;

// Switch
int iSwitch = 4;
String sO = "";

// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);

// LED Green
int iLEDGreen = 6;

// EEPROM Unique ID Information
String uid = "";

// Software Version Information
String sver = "14-22";

void loop() {

  // Laser
  isLaser();

  // Display Laser
  isDisplayLaser();

  // Delay
  delay( 100 );

}

getDisplay.ino

Arduino
// getDisplay
// Crowbits - OLED 128X64 UID
// Display UID
void isDisplayUID(){

  // Set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Don Luc Electron");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print( sver );

}
// Display Laser
void isDisplayLaser(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print( "Laser" );
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print( sO );
  
}

getEEPROM.ino

Arduino
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getLaser.ino

Arduino
// Laser
// is Laser
void isLaser(){

 // Switch
 if(digitalRead(iSwitch)){
  
  // Laser Pointer
  digitalWrite(iLaserPointer, HIGH);
  // LED Green
  digitalWrite(iLEDGreen, HIGH);
  // On
  sO = "On";
  
 }
 else{

  // Laser Pointer
  digitalWrite(iLaserPointer, LOW);
  // LED Green
  digitalWrite(iLEDGreen, LOW);
  // Off
  sO = "Off";

 }

}

setup.ino

Arduino
// Setup
void setup()
{
 
  // Delay
  delay(100);
  
  // isUID EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // Initialize the LED Green
  pinMode(iLEDGreen, OUTPUT);

  // Delay
  delay(100);

  // Laser Pointer
  pinMode(iLaserPointer, OUTPUT); 

  // Delay
  delay( 100 );

  // Switch
  pinMode(iSwitch, OUTPUT);

  // Delay
  delay( 100 );

  // Display UID
  isDisplayUID();
  
  // Delay 10 Second
  delay( 5000 );

}

Credits

Luc Paquin
41 projects • 4 followers
Teacher, Instructor, E-Mentor, R&D and Consulting -Programming Language -Microcontrollers -IoT -Robotics -Machine Learning -AI -Sensors

Comments