Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <SD.h>
- const int chipSelect = 10;
- void setup(){
- Serial.begin(9600);
- pinMode(10, OUTPUT);
- if (!SD.begin(chipSelect)) {
- Serial.println("kartu memori error");}}
- void loop(){
- String dataString = "";
- for (int analogPin = 0; analogPin < 3; analogPin++) {
- int sensor = analogRead(analogPin);
- dataString += String(sensor);
- if (analogPin < 2) {
- dataString += ",";}}
- File dataFile = SD.open("datalog.txt", FILE_WRITE);
- if (dataFile) {
- dataFile.println(dataString);
- dataFile.close();
- Serial.println(dataString);}
- else {
- Serial.println("file datalog.txt error");}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement