Categories
Statistics
Flag Counter
Since 08.08.2014
Counts only, if "DNT = disabled".

Your IP is 54.163.158.163
ec2-54-163-158-163.compute-1
Info
Valid HTML 4.01 Transitional Creative Commons Lizenzvertrag
rss
เราจะทำแบบวิศวกรผู้ยิ่งใหญ่
We love the King
Your valuable opinion :
5 stars

Avg. 5.00 from 2 votes.



Arduino-Code-Snippets.php   5971 Bytes    28-07-2016 09:58:19


Arduino Genuino Code Snippets


My personal "cloud" storage



As the title suggests this is a collection of self written code to be copy-pasted into future projects. It is likely possible that smarter solutions exist elsewhere ...






#1 HEXDUMP OF AN EEPROM



Double click on code to select ...


/* ////////////////////////////////////////////////////////////////// 
HEXDUMP OF AN EEPROM
http://www.changpuak.ch/electronics/Arduino-Code-Snippets.php
////////////////////////////////////////////////////////////////// */

// Import library for I2C / TWI devices
#include <Wire.h>

// Define eeprom address
const byte I2CADRESSE = 0x50 ;

// In Setup add
Wire.begin();
Serial.begin(9600);  // because data is send to console

// And here comes the function ...
void ReadEeprom()
{
byte rdata ;
  for (int address = 0; address < 512; address+=8) 
  {  
    if ( address < 16 ) Serial.print("0");
    if ( address < 0x100 ) Serial.print("0");
    Serial.print(address,HEX);  
    Serial.print("\t"); 
    // One row, HEX
    for (int add = 0; add < 8; add++) 
    { 
    Wire.beginTransmission(I2CADRESSE); 
    Wire.write((address+add) >> 8);   // MSB
    Wire.write((address+add) & 0xFF); // LSB    
    Wire.endTransmission();  
    Wire.requestFrom(I2CADRESSE,1);
    if (Wire.available()) rdata = Wire.read();
    if (rdata<16) Serial.print("0");  
    Serial.print(rdata, HEX);
    Serial.print(" ");
    }
    Serial.print("\t");
    // One row, ASCII
    for (int add = 0; add < 8; add++) 
    { 
    Wire.beginTransmission(I2CADRESSE);  
    Wire.write((address+add) >> 8);   // MSB
    Wire.write((address+add) & 0xFF); // LSB    
    Wire.endTransmission();  
    Wire.requestFrom(I2CADRESSE,1);
    if (Wire.available()) rdata = Wire.read();
    if (rdata < 32) 
    {
    Serial.print(".");
    }
    else if (rdata > 126) 
       {
       Serial.print(".");
       }
       else
          {
          Serial.print(char(rdata));
          }
    Serial.print(" ");
    }
    Serial.println();  
  } 
  Serial.print("\n");  

Serial.println("\nO.K.\n\n");
}

// ////////////////////////////////////////////////////////////////// 
// END OF FILE.
// ////////////////////////////////////////////////////////////////// 




✈ Share your thoughts


✈ Nothing more to be seen below this point ? Maybe your browser blocks the facebook iframe.
The webmaster does not read the comments regularly. Urgent questions should be send via email.








 
t1 = 3883 d

t2 = 551 ms

★ ★ ★  Copyright © 2006 - 2017 by changpuak.ch  ★ ★ ★

PRchecker.info Impressum