지금 sd 카드에 라듐센서 값을 저장하려고 하는데요 어디서 오류가 났는지 확인좀 부탁드립니다.
지금 sd 카드에 파일은 만들어지는데 데이터 저장이 안되고 있습니다.
#include
#include
#include
File sdcard;
int addr = 0x18;
byte buffer[2] = {0.0};
void setup() {
Wire.begin();
}
void loop() {
delay(1000);
Gamma_Mod_Read_Value;
Sdcard;
}
void Gamma_Mod_Read_Value(){
Gamma_Mod_Read(0xB2);
}
void Gamma_Mod_Read(int cmd){
Wire.beginTransmission(addr);
Wire.write(cmd);
Wire.endTransmission();
delay(10);
Wire.requestFrom(addr,2);
byte i = 0;
while(Wire.available());{
buffer[i] = Wire.read();
i++;
} Print_Result(cmd); }
void Print_Result(int cmd)
{
float value = 0.0f;
switch(cmd){ case 0xB2:value = buffer[0] + (float)buffer[1]/100;
}
}
void Sdcard(int cmd){
sdcard = SD.open("result.txt",FILE_WRITE);
sdcard.println(cmd);
sdcard.close();
}
|