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.
Fork of _Lektion_07 by
main.cpp
- Committer:
- Enenkel
- Date:
- 2015-03-09
- Revision:
- 0:e2129defbaf4
- Child:
- 1:a824701b2a17
File content as of revision 0:e2129defbaf4:
/* HIMBED _Lektion_07 "LDR AnalogIn"
BUKME Graz, by Enenkel 26.2.2015
author: Gottfried Enenkel HTL BULME
email: ene@bulme.at
Aufbage:
1) Lade die Software und analysiere sie.
Bewege den Finger zum LDR und sieh was passiert.
2) Erstelle einen lichtabhängigen Leuchtbalken über 8 LED
je dünkler desto mehr LED leuchten
3) Wer gut ist,
kann einen Lichtbalken über 12 LED programmieren */
// ********** Definitionen *****************
#include "mbed.h"
DigitalOut ledD1(P1_8); // LED D10
DigitalOut ledD2(P1_9);
DigitalOut ledD3(P1_10);
DigitalOut ledD4(P1_11);
AnalogIn LDR(P0_12); // Analoges einlesen des LDR
// LDR liefert einen analogen Wert
// zwischen 0 und 1
// ************* Hauptprogramm ******************
int main()
{
while(1)
{
if(LDR <= 0.07) // Ab einer Lichtstärke von 0.15 oder kleiner
ledD4 = 1; // Ist die LED D1 EIN
else
ledD4 = 0;
if (LDR <= 0.1)
ledD3=1;
else
ledD3=0;
if (LDR <= 0.15)
ledD2=1;
else
ledD2=0;
if(LDR <= 0.2)
ledD1=1;
else
ledD1=0;
}
}
// **************** ENDE ************************
