Pages: [1]   Go Down
Author Topic: arduino mega + sd card connected with resistor  (Read 1930 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,
i m try to write on my sd card connected with resistor to arduino
i try this : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206874649/0
 
but i have may errors at compiling :
arduino sd card example.cpp:1:30: error: sd-reader_config.h: No such file or directory
arduino sd card example.cpp:2:20: error: sd_raw.h: No such file or directory
arduino sd card example.cpp:3:27: error: sd_raw_config.h: No such file or directory
arduino sd card example.cpp:13: error: 'byte' does not name a type
arduino sd card example.cpp:16: error: 'byte' does not name a type
arduino sd card example.cpp: In function 'void setup()':
arduino sd card example.cpp:22: error: 'Serial' was not declared in this scope
arduino sd card example.cpp:23: error: 'delay' was not declared in this scope
arduino sd card example.cpp:26: error: 'sd_raw_init' was not declared in this scope
arduino sd card example.cpp: In function 'void loop()':
arduino sd card example.cpp:39: error: 'Serial' was not declared in this scope
arduino sd card example.cpp:41: error: 'incomingByte' was not declared in this scope
arduino sd card example.cpp: In function 'int sample()':
arduino sd card example.cpp:61: error: 'byte' was not declared in this scope
arduino sd card example.cpp:61: error: expected `;' before 'low'
arduino sd card example.cpp:62: error: expected `;' before 'high'
arduino sd card example.cpp:63: error: expected `;' before 'inByte'
arduino sd card example.cpp:65: error: 'Serial' was not declared in this scope
arduino sd card example.cpp:72: error: 'inByte' was not declared in this scope
arduino sd card example.cpp:75: error: 'analogRead' was not declared in this scope
arduino sd card example.cpp:76: error: 'DEC' was not declared in this scope
arduino sd card example.cpp:80: error: 'low' was not declared in this scope
arduino sd card example.cpp:81: error: 'high' was not declared in this scope
arduino sd card example.cpp:86: error: 'tempBytes' was not declared in this scope
arduino sd card example.cpp:89: error: 'sd_raw_write' was not declared in this scope
arduino sd card example.cpp:94: error: 'delay' was not declared in this scope
arduino sd card example.cpp: In function 'int readDisk()':
arduino sd card example.cpp:106: error: 'byte' was not declared in this scope
arduino sd card example.cpp:106: error: expected `;' before 'low'
arduino sd card example.cpp:107: error: expected `;' before 'high'
arduino sd card example.cpp:108: error: expected `;' before 'info'
arduino sd card example.cpp:111: error: 'Serial' was not declared in this scope
arduino sd card example.cpp:114: error: 'info' was not declared in this scope
arduino sd card example.cpp:114: error: 'sd_raw_read' was not declared in this scope
arduino sd card example.cpp:119: error: 'low' was not declared in this scope
arduino sd card example.cpp:120: error: 'high' was not declared in this scope
arduino sd card example.cpp:124: error: 'DEC' was not declared in this scope
arduino sd card example.cpp: In function 'void printWelcome()':
arduino sd card example.cpp:132: error: 'Serial' was not declared in this scope
arduino sd card example.cpp: In function 'int print_disk_info()':
arduino sd card example.cpp:146: error: aggregate 'sd_raw_info disk_info' has incomplete type and cannot be defined
arduino sd card example.cpp:147: error: 'sd_raw_get_info' was not declared in this scope
arduino sd card example.cpp:153: error: 'Serial' was not declared in this scope
arduino sd card example.cpp:155: error: 'HEX' was not declared in this scope
arduino sd card example.cpp:161: error: 'DEC' was not declared in this scope


What does it mean?
I have copied the library SDcard in  libraries

my board is the mega 1280
Logged

Espoo, Finland
Offline Offline
God Member
*****
Karma: 7
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code is missing.

Cheers,
Kari
Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the code is here :
le library is on this post : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206874649/0

Code:
#include <sd-reader_config.h>
#include <sd_raw.h>
#include <sd_raw_config.h>





int print_disk_info();
int sample();
int readDisk();

byte incomingByte;
void printWelcome();
long int address;
byte tempBytes[2];


void setup()
{

  Serial.begin(9600);
  delay(1000);

  printWelcome();
  if(!sd_raw_init())
  {
     Serial.println("MMC/SD initialization failed");
  }
  print_disk_info();
}



void loop()
{
    int i;

    if(Serial.available()>0)
    {
       incomingByte=Serial.read();

     switch(incomingByte)
     {
         case 114:
               readDisk();
               break;
         case 115:
               sample();
               break;
         default:
               break;
     }
    }
}

int sample()
{
    int i,j;
    int temp;
    byte low;
    byte high;
    byte inByte;

    Serial.println();
    Serial.println();
    Serial.println("Sampling..");
    for(i=0;i<500;i=i+2)
    {
      if(Serial.available()>0)
      {
        inByte=Serial.read();
        if(inByte==113) return 0;
      }
      temp=analogRead(0);
      Serial.print(temp,DEC);
      Serial.print(" ");

      //Convert int to 2 bytes
      low=temp&0xFF;
      high=temp>>8;
     // Serial.print(temp,DEC);
      //Serial.print(low,DEC);
      //Serial.print(high,DEC);

      tempBytes[0]=low;
      tempBytes[1]=high;

      if(!sd_raw_write(i,tempBytes,2))
      {
        Serial.print("Write error");
      }
      //sd_raw_sync();
      delay(5000);

  Serial.println();

    }

    return 1;
}


int readDisk()
{
    byte low;
    byte high;
    byte info[2];
    int i;
    int  result;
    Serial.println();
    for(i=0;i<50;i=i+2)
    {
      sd_raw_read(i,info,2);

      //Serial.print(info[0],DEC);
      //Serial.print(" ");
      //Serial.print(info[1],DEC);
      low=info[0];
      high=info[1];
      result=high<<8;
      //result<<8;
      Serial.print(" ");
      Serial.print(result+low,DEC);
      Serial.print(" ");
    }

}

void printWelcome()
{
    Serial.println("------------------------");
    Serial.println("Data sampling system");
    Serial.println("send r to read disk");
    Serial.println("send s to start sampling");
    Serial.println("send q to stop sampling");
    Serial.println("Ready.....");
    Serial.println("-------------------------");
}


int print_disk_info()
{


    struct sd_raw_info disk_info;
    if(!sd_raw_get_info(&disk_info))
    {
      return 0;
    }


    Serial.println();
    Serial.print("rev:    ");
    Serial.print(disk_info.revision,HEX);
    Serial.println();
    Serial.print("serial: 0x");
    Serial.print(disk_info.serial,HEX);
    Serial.println();
    Serial.print("date:   ");
    Serial.print(disk_info.manufacturing_month,DEC);
    Serial.println();
    Serial.print(disk_info.manufacturing_year,DEC);
    Serial.println();
    Serial.print("size:   ");
    Serial.print(disk_info.capacity,DEC);
    Serial.println();
    Serial.print("copy:   ");
    Serial.print(disk_info.flag_copy,DEC);
    Serial.println();
    Serial.print("wr.pr.: ");
    Serial.print(disk_info.flag_write_protect_temp,DEC);
    Serial.print('/');
    Serial.print(disk_info.flag_write_protect,DEC);
    Serial.println();
    Serial.print("format: ");
    Serial.print(disk_info.format,DEC);
    Serial.println();
    Serial.print("free:   ");

    return 1;
}




Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 653
Posts: 50888
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
#include <sd-reader_config.h>
#include <sd_raw.h>
#include <sd_raw_config.h>

Quote
arduino sd card example.cpp:1:30: error: sd-reader_config.h: No such file or directory
arduino sd card example.cpp:2:20: error: sd_raw.h: No such file or directory
arduino sd card example.cpp:3:27: error: sd_raw_config.h: No such file or directory

Well, it would seem that you have failed to download/properly install some libraries.
Logged

Pages: [1]   Go Up
Jump to: