Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int EI, cont=0, media=512;
- const byte led = 3;
- const byte botao = 4;
- bool state = false;
- void setup(){
- pinMode( led, OUTPUT );
- pinMode( botao, INPUT );
- digitalWrite( led, LOW );
- }
- void loop()
- {
- if( !state ) EI = analogRead(A1);
- if( EI < media && !state )
- cont+=25;
- else
- cont = 0;
- if( cont >= 5000 && !state ){
- digitalWrite( led, HIGH );
- state = true;
- }
- if( state ){
- if( digitalRead( botao ) == HIGH ){
- state = false;
- digitalWrite( led, LOW );
- cont = 0;
- }
- }
- delay (25);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement