0% found this document useful (0 votes)
2 views

Arduino and Genuino 101 Development Workshop - Agus Kurniawan Part 016

Arduino and Genuino 101 Development Workshop - Agus Kurniawan

Uploaded by

SANTOSH KHANAL
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Arduino and Genuino 101 Development Workshop - Agus Kurniawan Part 016

Arduino and Genuino 101 Development Workshop - Agus Kurniawan

Uploaded by

SANTOSH KHANAL
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Close and run again Arduino software. Let’s start to build a program.

In this demo, we do the following actions:

read EEPROM size using length()


write data into EEPROM using write()
read data from EEPROM using read()
clear all data on EEPROM using write() with value 0 on all EEPROM addresses

To achieve these actions, you can start to write program on Arduino software.
Write this program.
#include <CurieEEPROM.h>

byte value;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
}

void loop() {
// get a size of EEPROM
Serial.print("EEPROM size: ");
Serial.print(EEPROM.length());
Serial.println(" bytes");

// write data into EEPROM on address 0, 5, 10


// value in byte = 0 .. 255
Serial.print("Writing EEPROM data…");
EEPROM.write(0, 30);
EEPROM.write(5, 135);
EEPROM.write(10, 211);
Serial.println("Done");

// read EEPROM on address 0, 5, 10


value = EEPROM.read(0);
Serial.print("value ADD 0 = ");
Serial.println(value);

value = EEPROM.read(5);
Serial.print("value ADD 5 = ");
Serial.println(value);

value = EEPROM.read(10);
Serial.print("value ADD 10 = ");
Serial.println(value);

// clear all EEPROM data


Serial.print("Clearing EEPROM data…");
for (int i = 0 ; i < EEPROM.length() ; i++) {
EEPROM.write(i, 0);
}
Serial.println("Done");

// turn the LED while finished


digitalWrite(13, HIGH);
Serial.println("Finished!!");

delay(5000);

}
Save this program as EEPROMDemo.
Now you can compile and upload the program into Arduino board. If done, open Serial
Monitor to see program output.
A sample of program output can be seen in Figure below.
9. Working with Arduino Firmata

This chapter explains how to control Arduino/Genuino 101 board from computer using
Firmata.

You might also like