Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed sd_kart_yazma_okma TextLCD DHT11
Revision 2:5004004f091d, committed 2019-10-30
- Comitter:
- marvas
- Date:
- Wed Oct 30 08:37:03 2019 +0000
- Parent:
- 1:42257d3b1384
- Commit message:
- yeni
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 30 08:08:44 2019 +0000
+++ b/main.cpp Wed Oct 30 08:37:03 2019 +0000
@@ -4,12 +4,14 @@
#include "SDFileSystem.h"
Timer sure;
DigitalIn btn(PC_13);
+DigitalOut kartled(LED1);
+AnalogIn ldr(A0);
SDFileSystem sd(PB_15, PB_14, PB_13, PB_1, "sd"); // mosi, miso, sclk, cs(scl)
TextLCD lcd(D11, D12, D7, D8, D9, D10); // rs, e, d4-d7
DHT11 t(D3);
volatile char sicaklik;
-
+volatile float isik;
unsigned char c;
void sicaklikmetodu()
{
@@ -20,17 +22,33 @@
sicaklik= t.readTemperature();
lcd.cls();
lcd.printf("Sicaklik: %d",sicaklik);
- printf("Sicaklik: %d",sicaklik);
+ //printf("Sicaklik: %d",sicaklik);
sure.reset();
}
}
+ void ldrmetodu()
+ {
+ isik=ldr.read();
+ if(isik==1)
+ {
+ kartled=0;
+ //printf("Led OFF\n");
+ }
+ else
+ {
+ kartled=1;
+ //printf("Led ON\n");
+ }
+ //printf("Isik Seviyesi: %f \n",ldr.read());
+ }
int main() {
btn.mode(PullUp);
mkdir("/sd", 0777);
while(1)
{
+ ldrmetodu();
if(btn==0)
{
set_time(1572432498);
@@ -38,14 +56,17 @@
time_t seconds = time(NULL);
sicaklikmetodu();
- FILE *fp = fopen("/sd/sicaklik.txt", "w");
+ FILE *fp = fopen("/sd/sicaklik.txt", "a");
if(fp == NULL) {
error("Yazma icin dosya acilamadi \n");
printf("Yazma icin dosya acilamadi \n");
}
else {
//Sd karta yazar
- fprintf(fp, "%c, %s",sicaklik,ctime(&seconds));
+ if(isik<1)
+ fprintf(fp, "%c, %s LED ON",sicaklik,ctime(&seconds));
+ else
+ fprintf(fp, "%c, %s LED OFF",sicaklik,ctime(&seconds));
fclose(fp); //Dosya kapat
//
FILE *fpr = fopen("/sd/sicaklik.txt", "r");