NeoSteamLabs
Published © CC BY-SA

Project #12: Robotics - Unmanned Vehicles 1a - Mk05

Arduino UNO, Arduino Fio, EEPROM, Etc...

IntermediateProtip1 hour414
Project #12: Robotics - Unmanned Vehicles 1a - Mk05

Things used in this project

Story

Read more

Schematics

Fritzing

Code

DL2001Mk01p.ino

Arduino
// ***** Don Luc Electronics © *****
// Software Version Information
// Project #12: Robotics - Unmanned Vehicles 1a - Mk05
// 01-01
// DL2001Mk01p.ino 12-05
// Arduino UNO
// Screw Shield
// Adafruit RGB LCD Shield
// EEPROM with Unique ID
// Transmitter

// Include the library code:
#include <Adafruit_RGBLCDShield.h>
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Adafruit RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define GREEN 0x2

// Momentary Button
int yy = 0;
uint8_t momentaryButton = 0;

// Software Version Information
String sver = "12-05";
// Unit ID Information
String uid = "DT001";

void loop() {

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);    
  RGBLCDShield.print("Don Luc Electron");         // Don luc Electron
  
  momentaryButton = RGBLCDShield.readButtons();

  if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      isEEPROMw();
      yy = 1;
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      isUID();
      yy = 2;
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      UIDr();
      yy =3;
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {
      isEEPROMc();
      yy = 4;
    }

  }

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

getEEPROM.ino

Arduino
// getEEPROM
// Write and Read EEPROM with Unique ID for Unit
// Write EEPROM with Unique ID for Unit
void isEEPROMw() {
  
  // set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print( "Write" ); 
  
  // EEPROM
  int incb = 0;
  int v = 0;
  String msg = "";
  String emp = "";
  
  // Set Unit ID
  // The message starts with sid then is followed by 5 characters 
  // First clear a string buffer
  emp = "";
  // Loop through the 5 ID characters and write their ASCII (byte) value to the EEPROM
  for (int x = 0; x < 5; x++)
    {
       //Get ASCII value of character
       v = int(uid.charAt(x)); // + 5));
       //Add the actual character to the buffer so we can send it back to the PC
       emp = emp + uid.charAt(x + 5);
       //Write the value to the EEPROM
       EEPROM.write(x, v);
    }

   delay( 5000 );
   
}
// Read EEPROM with Unique ID for Unit
void isUID()
{
  // Unit ID
  String ruid = "";
  for (int x = 0; x < 5; x++)
  {
    ruid = ruid + char(EEPROM.read(x));
  }

  // set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print( ruid ); 

  delay( 5000 );
  
}
// Read uid
void UIDr()
{

   // set the cursor to column 0, line 1
   RGBLCDShield.setCursor(0, 1);
   RGBLCDShield.print( uid );

   delay( 5000 );
        
}
// Clear EEPROM
void isEEPROMc()
{

   // Clear EEPROM
   for (int i = 0 ; i < EEPROM.length() ; i++) {
      EEPROM.write(i, 0);
   }
    
   // set the cursor to column 0, line 1
   RGBLCDShield.setCursor(0, 1);
   RGBLCDShield.print( "Clear EEPROM" );

   delay( 5000 );
   
}

setup.ino

Arduino
// Setup
void setup() {
  
  // Adafruit RGB LCD Shield
  // 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 Electron");         // Don luc Electron
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Unique ID");                // Unique ID

  delay(5000);

  // Clear
  RGBLCDShield.clear();

}

DL2001Mk01Rp.ino

Arduino
// ***** Don Luc Electronics © *****
// Software Version Information
// Project #12: Robotics - Unmanned Vehicles 1a - Mk05
// 01-01
// DL2001Mk01Rp.ino 12-05
// Arduino Fio
// SparkFun FTDI Basic Breakout - 3.3V
// EEPROM with Unique ID
// Receiver

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Software Version Information
String sver = "12-05";
// Unit ID information
String uid = "DR001";

void loop() {
 
  // Write EEPROM with Unique ID for Unit
  int incb = 0;
  int v = 0;
  String emp = "";
  String ruid = "";
    
  // Set Unit ID
  // The message starts with uid then is followed by 5 characters 
  // First clear a string buffer
  emp = "";
  // Loop through the 5 ID characters and write their ASCII (byte) value to the EEPROM
  for (int y = 0; y < 5; y++)
  {
        
     // Get ASCII value of character
     v = int(uid.charAt(y)); // + 5));
     // Add the actual character to the buffer
     emp = emp + uid.charAt(y + 5);
     // Write the value to the EEPROM
     EEPROM.write(y, v);
         
  } 
    
  // Write EEPROM with Unique ID for Unit
  Serial.println( "Write ID Information");

  // Read ID Information
  // Unit ID
  for (int y = 0; y < 5; y++)
  {
    
    ruid = ruid + char(EEPROM.read(y));
    
  }
  
  // Read ID Information
  Serial.print( "Read ID Information: ");
  Serial.println( ruid );
  Serial.println( "Ok!" );
  ruid = "";

  delay( 5000 );
  
}

setup.ino

Arduino
// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial.begin(9600);

  // Serial
  Serial.print( "Software Version Information: ");
  Serial.println( sver );
  Serial.print( "Unit ID Information: ");
  Serial.println( uid );
  
  delay(5000);

}

Credits

NeoSteamLabs

NeoSteamLabs

30 projects • 12 followers
IT consultant with over 36 years of experience Instructor: Arduino, Raspberry Pi, Espressif, Robotics, Unmanned Vehicles, etc...

Comments