Luc Paquin
Published © CC BY

Project #12: Robotics - MOSFET - Mk28

Project #12: Robotics - MOSFET - Mk28

BeginnerFull instructions provided1 hour27
Project #12: Robotics - MOSFET - Mk28

Things used in this project

Hardware components

Elecrow Crowduino Uno - SD
×1
Elecrow Crowtail - Base Shield
×1
Elecrow Crowtail - I2C LCD
×1
Elecrow Crowtail - MOSFET 2.0
×1
Elecrow Crowtail - Mini Fan 2.0
×1
Adafruit 2 AAA Battery Holder with On/Off Switch
×1
Elecrow Crowtail - Rotary Angle Sensor 2.0
×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

DL2504Mk04p.ino

Arduino
/****** Don Luc Electronics © ******
Software Version Information
Project #12: Robotics - MOSFET - Mk28
DL2504Mk04p.ino
DL2504Mk04
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - I2C LCD
1 x Crowtail - MOSFET 2.0
1 x Crowtail - Mini Fan 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
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"

// MOSFET
int mosfetPin = 5;

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

// LED Green
int iLEDGreen = 6;

// Rotary Angle Sensor
int iPot = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;

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

// Software Version Information
String sver = "12-28";

void loop() {

  // isMOSFET
  isMOSFET();

  // Display MOSFET
  isDisplayMOSFET();

  // Delay
  delay( 500 );

}

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 MOSFET
void isDisplayMOSFET(){

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

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));
  }
  
}

getMOSFET.ino

Arduino
// MOSFET
// isMOSFET
void isMOSFET(){

  // Rotary Angle Sensor
  // Threshold => 0~255
  zz = analogRead( iPot );
  Threshold = map( zz, 0, 1024, 0, 255);

  // MOSFET
  // Threshold
  analogWrite(mosfetPin, Threshold);

}

setup.ino

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

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

  // Delay
  delay(100);

  // Rotary Angle Sensor
  pinMode(iPot, INPUT);
  
  // Delay
  delay(100);

  // Declare the motorPin as an OUTPUT:
  pinMode(mosfetPin, OUTPUT);

  // Delay
  delay( 100 );

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

}

Credits

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

Comments

Please log in or sign up to comment.