Emma Watson / Mbed 2 deprecated PURS_Vjezba3

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Opticki_senzor_long_code.cpp Source File

Opticki_senzor_long_code.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut myled1 (LED1);
00004 DigitalOut myled2 (LED2);
00005 DigitalIn switchInput1 (p5);
00006 DigitalIn switchInput2 (p15);
00007 
00008 int main() {
00009     
00010     int switchState1, switchState2;
00011     
00012         while(true){
00013         
00014             //lamapice se pale kada se prekine dovod svjetla na senzore
00015             switchState1 = switchInput1.read();
00016             switchState2 = switchInput2.read();
00017             
00018             if(switchState1 == 1) myled1 = 0;
00019             else myled1 = 1;
00020             
00021             if(switchState2 == 1) myled2 = 1;
00022             else myled2 = 0;
00023 
00024         }
00025     
00026 }