Pikir dan Rasa

cogito ergo sum

Bermain dengan array [tinkering Arduino]

leave a comment »

Sekedar tinkering dengan array pada Arduino


const word BAUDRATE = 9600;

char array01[] = {'1','2','3','4','5','6'};
char array02[7];

void setup(){
  char array03[] = {'7','8','9','1','2','3'};
  Serial.println("Isi array02 >> ");
  for(char ko = 0; ko < 5; ko++){
    array02[ko] = ko+5 ;
  char *p;
  p = array01;
  Serial.println("Tampilan >> ");

  Serial.println("array01 dengan pointer");
  Serial.println("array02 dengan bantuan \"for\" ");
  Serial.println("array02 casting dengan int");

void loop(){ 


void printtulis(char *data){ 

  Serial.println("Fungsi printtulis:");

void printtulisint(char *data2i){
  Serial.println("Fungsi printtulisint:");

void tulisArray02(){
  const int batas1 = ((sizeof(array02)/sizeof(char)));
  Serial.print("Nilai batas: ");
  for(int i=0; i < batas1;i++){




Keterangan dari situs Arduino:

For this reason you should be careful in accessing arrays. Accessing past the end of an array (using an index number greater than your declared array size – 1) is reading from memory that is in use for other purposes. Reading from these locations is probably not going to do much except yield invalid data. Writing to random memory locations is definitely a bad idea and can often lead to unhappy results such as crashes or program malfunction. This can also be a difficult bug to track down.

Unlike BASIC or JAVA, the C compiler does no checking to see if array access is within legal bounds of the array size that you have declared.





Written by sunupradana

January 1, 2012 at 8:17 pm

Posted in Electronics, Embedded Systems

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: